楚阿旗

博客园 首页 新随笔 联系 订阅 管理

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
posted on 2024-03-22 14:21  楚阿旗  阅读(14)  评论(0)    收藏  举报