Build YOUR OWN Dockerfile, Image, and Container
The goal is build our very own custom Docker container image. And it will be from scratch, bare bones, with an empty Dockerfile, and we will create, build, and run our very own custom Docker Image.
By doing so, My goal is to introduce you to some commands when building and maintaining images with Docker.
But first let’s understand:
- What is Docker?
- What is a Container?
- What is an Image?
Install Docker
To install docker, see Install Guide
-
What is a Container? A Docker container is like a special box that contains everything a computer program needs to run, so it can work the same way on any computer. It’s like a portable play-kit for software.
-
What is an Image? A Docker image is like a recipe or blueprint for a Docker container, telling it what to include and how it should behave. It’s like having instructions for building a specific lego set.
Docker commands
build image
docker build
build image with tag
docker build -t hello-web
list docker images
docker images
list docker containers
docker ps
list docker containers including stopped
docker ps -a
create container from image
docker run -d -p 80:80 <image id>
exec into running container
docker exec -it <container id> /bin/sh
stop running container
docker stop <container id>
remove a container
docker rm <container id>
remove an image
docker rmi <image id>