Skip to content
- Specify Base Image:
- Define a Working Directory:
- The name of the directory in which the container will execute commands
- Must be used, CD commands are not persisted across image layers.
- Copy current directory contents into container at
ADD . /nameofdir
- Expose a port outside of the container:
- Define an environment variable:
ENV NAME variable
- Define Command to Be Run:
- Add Files to Image:
ADD --CHOWN=<user>:<group> <name-of-file-source> <name-of-file-destination>
- Can also pull from URL
- Can unpack TAR files
- Copy Files to Image:
COPY --CHOWN=<user>:<group> <name-of-file-source> <name-of-file-destination>
- Doesn’t have capabilities of ADD named above.
- Run Command:
- Can provide in Exec or Shell Format, former is preferred, uses JSON array.
- Some choose not to use
ENTRYPOINT and put both command and parameters in
- Create Image Command:
docker image build -t <name-of-image> .
- Uses the Dockerfile in the current folder.
.dockerignore file to exclude files from being added to image.