Skip to content

Instantly share code, notes, and snippets.

@s-petit
Last active December 20, 2019 09:36
Show Gist options
  • Select an option

  • Save s-petit/684c01d679f554540b816eb7aff26f62 to your computer and use it in GitHub Desktop.

Select an option

Save s-petit/684c01d679f554540b816eb7aff26f62 to your computer and use it in GitHub Desktop.
Docker useful commands

List all containers with its restart policy

docker inspect -f "{{.Name}} {{ .HostConfig.RestartPolicy }}" $(docker ps -a -q)

Remove all containers

docker rm $(docker ps -a -q) -f

by name pattern (ex: '-dev')

docker rm $(docker ps -a --filter="name=-dev" -q) -f

Remove all images

docker rmi $(docker images -a --filter=dangling=true -q)

Deploy to dkbo

dkbo run \
      --detach \
      --env VIRTUAL_HOST="<APP_URL_FOR_NGINX>" \
      --env VIRTUAL_PORT=8080 \
      --env ENVIRONMENT=<ENV> \
      --name=<CHOOSE_CONTAINER_NAME> \
      --publish-all \
   	  <IMAGE>

How to recover a container in an inconsistent state

copy the corrupted file from the container, fix it locally, then recopy it inside the container.

docker cp docker_web_1:/etc/apache2/sites-enabled/apache.conf . (correct the file) docker cp apache.conf docker_web_1:/etc/apache2/sites-enabled/apache.conf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment