Skip to content

Instantly share code, notes, and snippets.

@dmitriyzyuzin
Last active June 26, 2021 16:12
Show Gist options
  • Save dmitriyzyuzin/1ab9b18ba38d2db660047e96b28a01f6 to your computer and use it in GitHub Desktop.
Save dmitriyzyuzin/1ab9b18ba38d2db660047e96b28a01f6 to your computer and use it in GitHub Desktop.
Docker cheat sheat

Docker

Building an image

Note: don't forget to create a Dockerfile in the same directory. Next command build new php-obfuscator image from current directory:

docker build -t php-obfuscator .

How to verify? Next command should print info about new image:

docker images | grep php-obfuscator

Run container

docker run --rm -v $(pwd):/usr/src/myapp --name php-container -it php-obfuscator /bin/bash

↑ creates a new container with php-container name. Why do we need other arguments?

  • --rm - remove the container after stopping it (exit 0, ctrl + C, whatever)
  • -v $(pwd):/usr/src/myapp - attach a docker's volume (host root directory : dir inside container)
  • -it <image_name> /bin/bash - create a shell

Remome all volumes except for three volume

docker volume rm $(docker volume ls -q | grep -vE "le_mysql_data|domentor_pg_data|adp_pg_data")

Remove all images

docker rmi $(docker images -q)

Run Database in container and expose port

docker run -d -v $(pwd)/db:/data/db -p 27017:27017 --name mongo-test mongo:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment