Create a Simple App Using Docker.
It is imperative for every cloud engineer to acquire proficiency in Docker, as this skill significantly streamlines tasks and enhances efficiency.
Docker is an open-source project and a containerization platform. It standardizes packages of applications and their dependencies into containers, which share the same OS kernel.
Scenario
You are a devops engineer that was tasked to create a docker container for the application the development team created.
OBJECTIVE
Our upcoming task involves the transformation of a Dockerfile, which includes the directives and files necessary for generating a Docker image. Subsequently, this image will be transformed into a container.
CREATING A DOCKER CONTAINER
Navigate into the terminal and move into the folder which has the Dockerfile. The Dockerfile uses the latest version of the nginx
image (which includes a configured installation of NGINX).
To build the image, from the folder run the docker build command.
docker build -t <dockerfilename> .
To verify and locate the image you just created run this command`:
docker images
Convert the image to a container with this command:
docker run -d -p 8081:80 <dockerfilename>
This will run in detached mode, so your terminal should return to the prompt immediately.
Verify the container is running with docker ps
. Confirm the port mapping with docker port <CONTAINERID>
.
Browse to http://localhost:8081 to view the container.
Congratulations on creating your first container!!!!.
Run a docker stop <CONTAINERID>
to stop the 2048 container app.
Run a docker rm <CONTAINERID>
to remove the 2048 container.