Article Directory
1. For mirroring operations
1. Download the nginx image -n to specify the namespace
ctr -n=default image pull --all-platforms docker.io/library/nginx:1.18.0
ctr -n=default image pull --platform linux/amd64 docker.io/library/nginx:1.18.0
- -n: Specifies the namespace, which namespace the image is downloaded to, and the image can only be found under this namespace later.
- --all-platforms: Extract all platform images
- –platform: extract the specified platform image
2. View the mirror image
ctr -n=default image list
3. Export image
ctr image export nginxv1.tar.gz docker.io/library/nginx:1.18.0
4. Import image
ctr image import nginxv1.tar.gz
5. Delete the mirror image
ctr image remove docker.io/library/nginx:1.18.0
6. Mount the mirror
Mount the nginx:1.18.0 mirror to /mnt
ctr image mount docker.io/library/nginx:1.18.0 /mnt/
7. Uninstall the image
umount /mnt
8. Mirroring and labeling
ctr image tag docker.io/library/nginx:1.18.0 16.32.15.100/nginx:1.18.0
9. Mirror image check
ctr image check
2. For container operations
- Static container: only creates the container and does not run the program in the container
- Dynamic container: create a container and run the program in the container
1. Create a static container
The created container image must exist locally, otherwise it cannot be created.
ctr container create docker.io/library/nginx:1.18.0 nginx-1
2. Check the container
ctr container ls
ctr container list
3. View container details
ctr container info nginx-1
4. Start the static container
After the static container is started, it will become a dynamic container
ctr task start -d nginx-1
- -d: run in the background, similar to docker run -d
5. Check the task
task to indicate the process information running in the container
ctr task ls
ctr task ps nginx-1
6. Enter the container
ctr task exec --exec-id 1 nginx-1 sh
curl http://127.0.0.1
- –exec-id: Specifies the ID of the command to be executed, which is unique
7. Run a dynamic container
ctr run -d --net-host docker.io/library/nginx:1.18.0 nginx-2
ctr task ls
- –net-host : Specify the network, host means sharing the network with the host
8. Hang the container
ctr task pause nginx-1
ctr task ls
9. Restoring the container
ctr task resume nginx-1
ctr task ls
10. Stop the container
ctr task kill nginx-1
11. Delete the container
ctr task rm nginx-1