#Deploying containers with Dockerfile Docker files are the second way of deploying containers. Instead of manually configuring the server and commiting the changes, we can do it all from a script.
- Open Visual Studio Code and create a new Dockerfile. (Open VS Code and save the file as a Dockerfile, no extension)
- Add the following lines to the file
FROM nginx
RUN apt-get update && apt-get install -y wget
WORKDIR /usr/share/nginx/html/
RUN rm index.html
RUN wget https://raw.githubusercontent.com/JesperJakobsen/Dockerdemo/master/index.html
- Copy the text
- Create a new folder the host with
mkdir <folder>
, then change your working directory to that foldercd foldername
- Create the dockerfile on the host with
touch Dockerfile
, thennano Dockerfile
, paste our commands and exit nano withCtrl + x
, pressY
to save the file. - Run the command
docker build -t <image-name> .
, this wil create the new image based on the public imagenginx
and deploy a simple webpage to the folder. - Run your new docker container with
docker run -d -p 80:80 <image-name>
- Now your website should be running, so get the IP from Azure and check that everything is fine.