Paulund

Docker Cheatsheet

docker build -t <tag name> . # Build Image
docker push <tag name> # Push Image

# Inheritance
FROM <BASE IMAGE> # Inherit from base image

# Variables
ENV APP_HOME /myapp # Set environment variable
RUN mkdir $APP_HOME # Use environment variable

ARG APP_HOME="" # Set build argument
RUN mkdir $APP_HOME # Use build argument

# Add Files Into Image
ADD filename.md /filename.md # Add file
COPY --chown=user:group local_filename.md /path/container_filename.md # Copy file

# Expose Ports
EXPOSE 80 # Expose port 80

# Run Commands
CMD ["executable", "param1", "param2"] # Run command
ENTRYPOINT ["executable", "param1", "param2"] # Run command

# Volumes
VOLUME /myapp # Create volume

# User
USER user # Set user

# Work Directory
WORKDIR /myapp # Set working directory

# Healthcheck
HEALTHCHECK --interval=5m --timeout=3s CMD curl -f http://localhost/ || exit 1 # Healthcheck

# Labels
LABEL version="1.0" # Add label

# Stop Signal
STOPSIGNAL SIGTERM # Stop signal