From LedHed's Wiki
(Created page with "== Overview == This is a list of common commands used to manage docker. For a complete command reference go here: https://docs.docker.com/engine/reference/commandline/docker/...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 19: | Line 19: | ||
== Start All Stopped Containers == | == Start All Stopped Containers == | ||
docker start $(docker ps -a -q -f status=exited) | docker start $(docker ps -a -q -f status=exited) | ||
+ | |||
+ | |||
+ | == Stop Container == | ||
+ | docker stop MyContainer | ||
+ | |||
+ | |||
+ | == Map a local port to a container == | ||
+ | docker run -it -p 6969:80 MyContainer | ||
+ | ''Note: this maps local port 6969 to container port 80'' | ||
+ | |||
+ | |||
+ | == Start a container automatically == | ||
+ | docker run -dit --restart unless-stopped MyContainer | ||
+ | |||
+ | |||
+ | == Start a container automatically with a port mapping == | ||
+ | docker run -dit -p 6969:80 --restart unless-stopped MyContainer | ||
+ | |||
== Version == | == Version == | ||
docker --version | docker --version | ||
+ | |||
+ | |||
+ | == Reference == | ||
+ | https://docs.docker.com/engine/reference/commandline/docker/ | ||
[[Category:Docker]] | [[Category:Docker]] |
Latest revision as of 06:19, 10 April 2021
Contents
Overview
This is a list of common commands used to manage docker. For a complete command reference go here: https://docs.docker.com/engine/reference/commandline/docker/
List All Containers
docker container list -a
Enter Container's Shell
docker exec -it MyContainer /bin/bash
MyContainer = the name of the container you want to access
Start Container
docker start MyContainer
Start All Stopped Containers
docker start $(docker ps -a -q -f status=exited)
Stop Container
docker stop MyContainer
Map a local port to a container
docker run -it -p 6969:80 MyContainer
Note: this maps local port 6969 to container port 80
Start a container automatically
docker run -dit --restart unless-stopped MyContainer
Start a container automatically with a port mapping
docker run -dit -p 6969:80 --restart unless-stopped MyContainer
Version
docker --version
Reference
https://docs.docker.com/engine/reference/commandline/docker/