Dockerfile - kimschles/schlesinger-knowledge GitHub Wiki
FROM
- Sets the base image for the rest of the Dockerfile instructions
- Sets up the envioronment: node.js, ruby, java, etc.
COPY
- The COPY instruction copies new files or directories from and adds them to the filesystem of the container at the path .
- copy directories or files from the source and add them to the destination container's filesystem
COPY <src> <dest>
COPY say_hello.sh /mydir/
- The original version
ADD
- The ADD instruction copies new files, directories or remote file URLs from and adds them to the filesystem of the image at the path .
-
ADD
lets you copy directories, files or files from URLS from the source and adds them to the filesystem of an image -
ADD
lets you add local files to your docker image- Local to what? Local directory
- The updated version
ADD say_hello.sh /
- Makes a copy of the file you're specifiying in the root director of the filesystem
COPY
vs. ADD
*
CMD
-
CMD
allows you to treat your docker container like an executable binary - If you only use
ENTRYPOINT
- An ENTRYPOINT allows you to configure a container that will run as an executable.
- Allows you to id which executable should be run when a container is started from your image
- Used more often
- The default command that gets run
CMD
vs. ENTRYPOINT
- You can manually override
CMD
withdocker run
- Entrypoint will overrider commands with
docker run
RUN
- create a new container, start it and run a process in it
- this command will run the commands in a new layer on top of the current image and commit the results
EXEC
- when you want to run a command in an existing container
RUN
vs EXEC
EXPOSE
- The port on which the container listens for connetions
- Apache Web Server:
EXPOSE 80
- MongoDB:
EXPOSE 27017
IP Address is like an address A port is like a mailbox in an apartment building
Like a telephone switchboard. A port is like the jack.
ARG
- Allows the developer to set values during the
docker build
process
HEALTHCHECK
- A way to check if a running container is healthy