In our previous post we saw how to perform our first Hello World in Docker. Through a simple Dockerfile we created an image from another and initialized a web server with our Hello World. Today's exercise will be slightly different, and we will create an image from a repo on Github.
This same exercise is in the Getting Started of any clean installation of Docker. The first command we will use will be the following:
docker run --name repo alpine/git clone https://github.com/docker/getting-started.git
This command creates a new container from the
alpine/git image, if it does not exist, downloads it, and downloads the repository passed as a parameter inside the container. After this we can copy the contents inside the container to our local file system and build a new docker image.
docker cp repo:/git/getting-started/ . cd getting-started docker build -t docker101tutorial .
Finally we can run our container with the following command.
docker run -d -p 81:80 --name docker-tutorial docker101tutorial
We should be able to access the application with the following URL.