diff --git a/06-containers-on-the-cloud.html b/06-containers-on-the-cloud.html index fa59d1b2..94cb5999 100644 --- a/06-containers-on-the-cloud.html +++ b/06-containers-on-the-cloud.html @@ -539,7 +539,7 @@
alpine-python
container image.
-If we try running the container and Python script, what happens?
+We can run a container from the alpine-python container image +using:
$ docker container run alice/alpine-python python3 sum.py
+$ docker container run alice/alpine-python
+What happens? Since the Dockerfile
that we built this
+container image from had a CMD
entry that specified
+["python3", "--version"]
, running the above command simply
+starts a container from the image, runs the
+python3 --version
command and exits. You should have seen
+the installed version of Python printed to the terminal.
Instead, if we want to run an interactive Python terminal, we can use
+docker container run
to override the default run command
+embedded within the container image. So we could run:
The -it
tells Docker to set up and interactive terminal
+connection to the running container, and then we’re telling Docker to
+run the python3
command inside the container which gives us
+an interactive Python interpreter prompt. (type exit()
+to exit!)
If we try running the container and Python script, what happens?
+What does the error message mean? Why might the Python inside the -container not be able to find or open our script?
+Question: What does the error message mean? Why might the Python +inside the container not be able to find or open our script?
+This question is here for you to think about - we explore the answer +to this question in the content below.
Let’s try running the command now:
-$ docker container run --mount type=bind,source=${PWD},target=/temp alice/alpine-python python3 sum.py
+$ docker container run --mount type=bind,source=${PWD},target=/temp alice/alpine-python python3 sum.py
But we get the same error!
/temp
– so we
need to include that in the path to the script. This command should give
us what we need:
-$ docker container run --mount type=bind,source=${PWD},target=/temp alice/alpine-python python3 /temp/sum.py
+$ docker container run --mount type=bind,source=${PWD},target=/temp alice/alpine-python python3 /temp/sum.py
Note that if we create any files in the /temp
directory
while the container is running, these files will appear on our host
@@ -562,12 +601,12 @@