Dockerize your runnable application

Ever run into an issue with environments when running other peoples code? Don’t have the proper modules in your environment? Don’t want to modify your existing environment just to run a CLI program?

Dockerize it! Make the application runnable on any machine using docker. Using a default alpine program date as an example

Step 1: Create a Dockerfile wrapping your application

# Base image
FROM alpine
# Copy your runnable program with the COPY 
# docker command.

# The first argument of the ENTRYPOINT will be command executed when 
# the docker container is run
ENTRYPOINT ["date"] 

Step 2: Build the dockerfile

docker build .

Step: 3 Run the program with docker run

docker run [container-name] -h

Full example

Leave a Reply

Your email address will not be published. Required fields are marked *