Wednesday, February 15, 2023

Docker Cheat Sheet

----------------------------------------------------------------------
Docker service
----------------------------------------------------------------------

Starting the daemon
sudo service docker start


----------------------------------------------------------------------
Managing Images
----------------------------------------------------------------------


List all Images
docker images

Rename Image...by aliasing the image
docker tag <id> <alias>

Remove Image (untagging)
docker rmi <alias>

Remove Unused Images
docker image prune [-a]

----------------------------------------------------------------------
Running Containers
----------------------------------------------------------------------


See running containers
docker ps

Launch container from image
docker run -it [-d] [--rm] [--network <name>]  <image_id> 

where -d started detached; --rm removes on exit; --network network name to use (see `docker network ls`)

Retain image changes
docker commit <container_id> <group>/<alias>

Attach and execute shell
docker exec -it <container_id> bash

Build image from local Dockerfile
docker build . -t <alias>

Attach to running shell
docker attach <container_id>

Drop out of running shell - but leave running
ctl-p ctl-d

View container logging
docker logs <container_id>


----------------------------------------------------------------------
Docker and Docker-Compose Runtime
----------------------------------------------------------------------

Start docker-compose containers
docker-compose up -d



















No comments:

Post a Comment