Create An Image

Create Docker Container

Create and start a docker container (docker container run) that is interactive (-it), called “new-project” (--name new-project), and is based on python:3.8-slim. Then run /bin/bash to get a terminal.

docker container run -it --name new-project python:3.8-slim /bin/bash
Unable to find image 'python:3.8-slim' locally
3.8-slim: Pulling from library/python
bf5952930446: Pull complete 
385bb58d08e6: Pull complete 
ab14b629693d: Pull complete 
7a5d07f2fd13: Pull complete 
56745e40505a: Pull complete 
Digest: sha256:f7edd1bb431a224e7f4f3e23cbb22738e82f4895a6d28f86294ce006177360c3
Status: Downloaded newer image for python:3.8-slim
[email protected]:/#

Create File In Container

Create a file (touch) called analysis.py.

touch analysis.py

Exit Container

exit

Create New Image

Create a new image (docker container commit) from the new-project container called new-project-with-analysis-file. Add author info (-a "Chris Albon") and a commit message (-m "Added analysis file")

docker container commit -a "Chris Albon" -m "Added analysis file" new-project new-project-with-analysis-file
sha256:0684311a4db5010d334dc524112c83daa891dc3d31edd720b372edfd7b1ab94a