This is a draft cheat sheet. It is a work in progress and is not finished yet.
Cheatsheet version
Version |
1.0.0 |
Last update |
4/7/2018 |
Docker version |
Docker-CE v18 |
Run containers
Search Docker Hub for an image |
docker search |
Pull an image |
docker pull |
Run an image |
docker run |
Run (as daemon) |
docker run -d |
Run (and open port) |
docker run -p 80:80 |
List running containers |
docker ps |
Stop a container |
docker stop |
Resource constraint
Max memory (units: b,k,m,g) |
-m 300m |
Memory swap |
--memory-swap="1g" |
CPU |
--cpus="1.5" |
|
|
Docker compose
Sample docker-compose.yml file:
version: "3"
services:
glassfish:
image: glassfish
container_name: glassfish
ports:
- "8080:8080"
- "4848:4848"
deploy:
resources:
limits:
cpus: '1'
memory: 4G
stdin_open: true
tty: true
Connect to container:
docker-compose exec glassfish sh
|
|