Steps to create and run containers:
1. Create a Dockerfile
2. Use the Dockerfile to create a container image
3. Use the container image to create a running container
Dockerfile example
FROM alpine #Defines the base image CMD ["echo", "Hello World!"] #Prints the words "Hello World!" on the terminal
Docker build command
docker build -t my-app:v1 .
Docker image verification
docker images
Docker run command
docker run my-app:v1
docker ps -a #To verify the details of the container created
Docker commands
|
Docker command |
Purpose | Example |
| build | Creates cotainer images from a Dockerfile | docker build -t my-app:v1 |
| images | Lists all images, repositories, tags, and sizes | docker images |
| run | Creates a container from an image | docker run -p 8080:80 nginx |
| push | Stores images in a configured registry | docker push my-app:v1 |
| pull | Retrieves images from a configured registry | docker pull nginx |
浙公网安备 33010602011771号