Created
December 27, 2019 17:33
-
-
Save karthikax/6274ef18a5fe2ad9389bbdeddcfba25f to your computer and use it in GitHub Desktop.
Docker basics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3 | |
# From here: https://hub.docker.com/_/python | |
# Python preinstalled | |
# You can use any image from docker hub | |
WORKDIR /usr/src/app | |
COPY my_file.py ./ | |
# Copy any file or directory here if needed. | |
RUN echo "Run any shell command here" | |
# like apt-get install | |
# pip install etc. | |
CMD [ "python", "./my_file.py" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install docker in your local machine | |
# Save the above Dockerfile in local | |
# In the same directory run the following to build your docker image | |
docker build -t my-python-app:latest . | |
# This will build and save image in local with image name my-python-app and tag latest | |
# Now you can run the container from that image by using following command | |
docker run -it my-python-app:latest | |
# At runtime you can | |
# - mount local folders into container using -v flag | |
# - expose port into host machine using -p flag | |
# - run in detached mode using -d flag | |
# etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment