Skip to content

Instantly share code, notes, and snippets.

@xtrmstep
Created August 12, 2022 05:46
Show Gist options
  • Save xtrmstep/01513b0cdcdc13636ca294b19ff09728 to your computer and use it in GitHub Desktop.
Save xtrmstep/01513b0cdcdc13636ca294b19ff09728 to your computer and use it in GitHub Desktop.
List of key notes about building and using Docker images

Here I gathered answers to small pitfalls which from time to time appears because you’re not doing some actions often. Such actions include using of .dockerignore, mounting files, SSL certificates for web servers in containers, etc.

Building of Docker images

  1. The file want be applied if it’s not located in the same directory where you run docker build command.
  2. Building of an image will fail if you use specific file names which you are ignoring. For example, if you write in Dockerfile COPY filetoignore.txt . and you are ignoring such file(s) in .dockerignore, you’ll get an error
  3. Paths inside Dockerfile are relative to the folder where you’re running command docker build and not to the one where your Dockerfile is located.
  4. Relative paths should use only current or child folders, since the parent one (or through it) is out of Docker context during building.

Docker-compose

  1. If you mount a file, but it’s not found in the host system, it will be mounted as a directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment