Skip to content

Instantly share code, notes, and snippets.

@gbarreiro
Created September 17, 2020 14:09
Show Gist options
  • Save gbarreiro/bd39bc15d4f4e5ef118d75a4c038bea3 to your computer and use it in GitHub Desktop.
Save gbarreiro/bd39bc15d4f4e5ef118d75a4c038bea3 to your computer and use it in GitHub Desktop.
Sample Dockerfile for creating a Docker image
# Use an Ubuntu image as base image
FROM ubuntu:latest
# Metadata for the container
LABEL description="This is a dummy container" author="Guillermo Barreiro"
# Set the working directory inside the container for the following Dockerfile instructions
WORKDIR /root
# Use an argument sent to the "docker build" command inside the Dockerfile
ARG USERNAME
RUN echo ${USERNAME} >> username
# Run several commands in a same line, for avoiding creating intermediate junk images
RUN /bin/bash -c 'apt-get update; apt-get install python3'
# Set environment variables
ENV foo_folder /home
# Copy files to the container
COPY script.py /script.py
# Define a volume (in the Dockerfile you cannot set the location of a volume inside the host machine)
VOLUME /root/shared
# Set the entrypoint for the container, that means, the command to be executed when run
ENTRYPOINT ["python3", "script.py"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment