Skip to content

cekinmezyucel/docker-cheat-sheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Docker Cheat Sheet

Installation

Note: To prevent to type sudo all the time. You have to add your linux user to docker group.

Version

Lists version of Docker

$ docker version

Info

Lists detailed information of Docker environment.

$ docker info

Help

Lists all Docker commands. Docker commands usually work like this "docker command subcommand".

$ docker --help

Container Run

This command download the nginx image and run container with given port information. First port is hosts ports you can think it's your local machine port. Second port is container's port. Ex. if the port configuration was like 8888:80 you have to navigate "localhost:8888" from your browser.

$ docker container run --publish 80:80 nginx

--detach or -d command lets container to run in background.

$ docker container run --publish 80:80 --detach nginx

You can name your container by --name command.

$ docker container run --publish 80:80 --detach --name webhost nginx

Assign environment variables by --env or -e parameter.

$ docker container run --publish 3306:3306 --detach --name db --env MYSQL_RANDOM_ROOT_PASSWORD=yes mysql

Container List

Lists running containers.

$ docker container ls

Lists all containers including stopped ones.

$ docker container ls -a

Container Logs

Lists container logs by container name.

$ docker container logs webhost

Container Process

List container processes by container name.

$ docker container top webhost

Container Stats

List container performance, memory etc. stats by container name or blank*. Blank name shows every running container stats.

$ docker container stats webhost*

Container Inspect

Inspect container processes by container name.

$ docker container top webhost  

Container Stop

Stop container by container id.

$ docker container stop 3 0 b

Container Delete

Delete containers by ids. You can use first letters of container ids if they are unique. Running containers will not delete by this command.

$ docker container rm f15 cf4 b8f d7b f9f

Deletes containers with force. Running containers will be deleted by this command.

$ docker container rm -f f15

About

Docker Cheat Sheet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published