Docker is a very useful tool for modern web development. It allows you encapsulate a computation with the operating system and associated libraries. In principle allowing you to worry less about implicit dependencies that you have on your code, as they must made clear by the docker file.

This post is just a list of useful commands and things to know about docker.

  • RUN <command> In a dockerfile, the RUN directive executes the <command> and then creates a new layer in the dockerfile.
  • CMD [...] A CMD, this command is run whenever the docker image is run without any other commands. See RUN-vs-CMD
  • docker images will list the images currently available in Docker.
  • docker ps will list the images currently running.
  • docker exec -it <instance_name> bash will start a bash shell inside of the docker instance name <instance_name>. Unfortunately, this is different to the image name.
  • docker-compose up Assumes the presence of a docker-compose.yml file. Will run the docker container configuration described in docker-compose.yml
  • docker-compose -f <filename> up run the filename <filename> instead of default.
  • docker-compose up --build Rebulids everything described in the docker-compes.yml file.