Création_d_une_image_pour_Nginx__english_

Creating an image for Nginx

Here we will create a minimalist Docker Nginx image, displaying the message Helloworld !.

First, let’s create the Dockerfile based on the image nginx:alpine:

cat <<EOF> Dockerfile
FROM nginx:alpine
ADD www.conf /etc/nginx/conf.d/
ADD index.html /usr/share/nginx/html/
EOF

Next, let’s create the file index.html:

cat <<EOF> index.html
<html>
<body>
<p>Helloworld !</p>
</body>
</html>
EOF

Now, let’s create a minimalist Nginx configuration file:

cat <<EOF> www.conf
server {
    listen 80;
    root /usr/share/nginx/html;
}
EOF

Let’s create the Docker nginx-helloworld image:

docker build -t nginx-helloworld .
Sending build context to Docker daemon  28.04MB
Step 1/3 : FROM nginx:alpine
alpine: Pulling from library/nginx

0c94c7c5: Already exists 
2de6f957: Pulling fs layer 
e8e54998: Pulling fs layer 
206a393c: Pulling fs layer 
Digest: sha256:9b22bb6d703d52b079ae4262081f3b850009e80cd2fc53cdcb8795f3a7b452ee
Status: Downloaded newer image for nginx:alpine
 ---> e5dcd7aa4b5e
Step 2/3 : ADD www.conf /etc/nginx/conf.d/
 ---> 79f1a2d79eb4
Step 3/3 : ADD index.html /usr/share/nginx/html/
 ---> b224ba239a06
Successfully built b224ba239a06
Successfully tagged nginx-helloworld:latest

Let’s launch the nginx server:

docker run -d -p 80:80 nginx-helloworld
41a87f447ed55da90c8aa105599b846bb9fd0a7ba9265d39142decd78e3e7cdd

Let’s check that the web server responds:

curl http://localhost
<html>
<body>
<p>Helloworld !</p>
</body>
</html>

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×