Docker CLI cheat sheet

In this tutorial, I have written some command for docker CLI cheat sheet. Docker the essential for DevOps Roles.

The build image from our Dockerfile.

$ docker build -t devopsroles/centos:latest .

Docker run a command in an image

docker run [options] IMAGE

Docker CLI cheat sheet

Manage containers

Docker Create a container from an image.

docker create [options] IMAGE
-a, --attach # attach stdout/err
-i, --interactive # attach stdin (interactive)
-t, --tty # pseudo-tty
--name NAME # name your image
-p, --publish 5000:5000 # port map
--expose 5432 # expose a port to linked containers
-P, --publish-all # publish all ports
--link container:alias # linking
-v, --volume `pwd`:/app # mount (absolute paths needed)
-e, --env NAME=hello # env vars

Example, Create and start a container

$ docker create -t -i fedora bash

Exec Run commands in a container.

docker exec [options] CONTAINER COMMAND
-d, --detach # run in background
-i, --interactive # stdin
-t, --tty # interactive

Example, Docker ssh container

$ docker exec -it 59e59adcc0b4 /bin/bash

Start and stop a container.

docker start [options] CONTAINER
-a, --attach # attach stdout/err
-i, --interactive # attach stdin

docker stop [options] CONTAINER

Manage containers using ps and kill.

$ docker ps
$ docker ps -a
$ docker kill $ID

Docker Images

Manages images.

$ docker images

Deletes images.

$ docker rmi b750fe78269d


Thought the article, You can use “Docker CLI cheat sheet as above. I hope will this your helpful.

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.