Docker Reference Guide
Writing A Dockerfile
Helpful Base Images:
Basic Template
Replace bracketed text below.
# Start with a base image
FROM [base-image]
# Run any configuration commands
RUN
# Set any environmental variables
ENV PATH="/root/.cargo/bin:${PATH}"
# Copy any required files and/or directories
# into the image
COPY
# Run any additional commands
# (Install environment?)
RUN
CMD [Run your script]
ENTRYPOINT [USE CMD or ENTRYPOINT - See below]
Principles
Every command is a layer. To minimize the build time:
- Put your most frequently updated commands toward the end of the docker file.
As an example, copying your code (which presumably you edit more frequently) should probably be one of your last steps..
- If possible, combine commands into one line to form a single layer.
Building a Docker Image
docker build -t <docker-image-name> .
Running a Docker Image
Syntax Suggestions:
docker run -p <host-port>:<container-port> \
-e <set environmental variables> \
<image-name>
Helpful notes:
docker run -p 9000:8080 \
-e AWS_ACCESS_KEY_ID=$aws_access_key \
-e AWS_SECRET_ACCESS_KEY=$aws_secret_access_key \
-e OUTPUT_BUCKET_NAME=$aws_bucket \
-e NSAND_ACCESS=$nsand_access_key \
-e NSAND_SECRET=$nsand_secret \
-e SAND_ACCESS=$sand_access_key \
-e SAND_SECRET=$sand_secret \
-e AWS_LAMBDA_FUNCTION_TIMEOUT=1800 \
-e AWS_REGION=$aws_region nodd-metrics-cleaner
Note: Using the Docker Run command with the -it flag is a good way to step into the running container to a bash shell to both develop and see what is going on.
More info on Docker Run: Docker Run Docs