Docker Basics
to exit container without killing it . first press CTRL+P and then CTRL+Q
Docker Commands
docker version //version information
docker info //host information
docker pull registry:5000/alpine //pull image
docker images ls //list images
docker images
docker run -dt registry:5000/alpine //run image in background
docker run -it registry:5000/alpine //run image in interactive mode
docker ps //list running containers
docker container ls
docker inspect [container ID] //inspect container
docker container //manage containers
docker image //manage images
docker network ls //list networks
docker network //manage networks
docker attach [container id] //attach a running container
docker exec -it [container id] /bin/sh //execute a command in container
docker stop [container id] //stop a running container
docker start [conatiner id] //start a stopped container
docker kill [container id] //kill a running container
//This dockerfile takes locally present alpine image as base and copies a script in it.
docker build -t registry:5000/alpine-mod //Build Docker image
docker push registry:5000/alpine-mod //Push the image
docker commit 182329d8e111 registry:5000/alpine-note //Commit container as an image
docker export -o alpine.tar [container id] //Export an image as tar archive
docker ps -a //list runnin and stopped containers
docker rm [container id]
//removing stopped containers
docker rmi -f registry:5000/alpine-note //Remove an image by name
docker rmi -f 896f0e5e18af //Remove an image by id
docker system prune -a //Remove stopped container, unused images/networks
Containered Basics
ctr --version //version info
ctr images pull --skip-verify --plain-http registry:5000/alpine:latest
//pull image
ctr images list //list images
ctr container create registry:5000/alpine:latest alpine //create container
ctr container list //list containers
ctr container info //check container info
ctr task start alpine //Start a task
ctr task attach alpine
//attach to a task
ctr task list //list tasks
ctr task pause alpine //pause a task
ctr tasks resume alpine
//resume a task
ctr task kill -s SIGKILL alpine //kill a task
ctr container delete alpine //delete container
ctr image export alpine.tar registry:5000/alpine:latest //export image to tar
ctr image push --skip-verify --plain-http registry:5000/alpine:latest
//push image
ctr image rm [image name] //remove image
Podman Basics
podman --version //version info
podman info //hosts info
podman pull registry:5000/alpine //pull image
podman images //list images
podman run -dt registry:5000/alpine //run image in background
podman run -it registry:5000/alpine sh //run image in interactive mode
podman ps //list running containers
podman inspect [container id] //inspect container
podman container --help //manage container
podman images --help //manage images
podman network ls //list netoworks
podman network --help //manage networks
podman attach [container id] //attach to running container
podman exec -it [container id] /bin/sh //exec cmd in running container
podman stop [container id] //stop container
podman kill [container id] //kill container
podman build -t registry:5000/alpine-mod -f containerfile //build container
podman push registry:5000/alpine-mod //push image
podman commit eba3ce455 registry:5000/alpine-note //commit snapshot a container
podman export -o alpine.tar [container id] //export image as tar
podman ps -a
podman rm [container id] //remove containers
podman rmi -f registry:5000/alpine-note //remove image by name
podman rmi -f 896f0e5e18af //remove image by id
podman system prune -a //remove stopped/unused container, image , networks
Containers with Runc
curl --insecure https://registry:5000/v2/_catalog
//check list of repos on private docker repo
curl --insecure https://registry:5000/v2/alpine/tags/list //check tags for alpine repo
//Pull “alpine:latest” docker image using skopeo and save it in OCI format.
skopeo --insecure-policy copy --src-tls-verify=false docker://registry:5000/alpine oci:alpine-oci:latest
//Check the image stored in OCI format.
ls -l
find alpine-oci
//Use umoci to convert OCI image to image bundle.
umoci unpack --image alpine-oci alpinefs
// Use the image bundle to create and run container using runc
runc run -b alpinefs ctrid
Last updated
Was this helpful?