User Tools

Site Tools


docker

This is an old revision of the document!


Docker

Docker commands with no particular order

Prune

Prune images

docker image prune

Prune networks

docker network prune

Prune volumes

docker system prune --volumes

Prune system

docker system prune

Add -a to prune everything

Run command args

  • –name container name
  • -e environmental variables
  • -p ports (local-port:remote-port)
  • -v volumes (local/folder:remote/folder)
  • –restart (always, never, unless-stopped, on-failure)

Exec commands in a container

docker exec -it <container-name or id> <command>

Restart all docker containers

docker restart $(docker ps -q)

Docker Compose

docker-compose exec commands

With the compose running (docker-compose up):

docker run <container-name-in-docker-compose> <command>

This command runs a new docker container to execute the command

  • –rm run the container and delete it after execution

To execute a command inside a running container:

docker-compose exec <container-name> <command>
  • -i interactive
  • -t tty allocation
docker.1611579073.txt.gz · Last modified: 2023/01/01 18:43 (external edit)