Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Once the image is successfully built we can run a container from it. The docker run command contains many different options that you might want to explore through the official reference. However, to keep things simple, here’s a command for running a container capable of providing a jupyter notebook that can be accessed from the outside:

 

 

 

Code Block
languagebash
themeMidnight
titleRun container
collapsetrue
 docker run -d -rm --p YYYY:8888 --name <container_name> <image_name>

 

  • -d means that the container will run in detached mode. I.e. it will run in the background while freeing up your current shell. 

  • --rm means that the container will be cleaned up (everything inside it will be deleted) after it has exited. A container exists when its root process (which if you used the tensorflow:latest-gpu parent image is a jupyter notebook) terminates. Skip this flag if you want to keep the container around after it has exited, just remember to clean it up yourself so that you don’t clutter up the system. 

  • -p maps a network port from the host machine to a port in the container. In the command above, we map YYYY, which should be an unused port number of the host machine, to port 8888 in the container, which is where the default jupyter process will listen. 

  • --name sets a name for the container. It is not needed, since the container also gets a hash ID, but it is good practice to mark it with a human readable string as well. For instance, if you called your image olanorm/myproject, you can call the container olanorm_myproject (since slashes are not allowed in container names). This name can be used to access the container when running extra commands in it or when you wish to shut it down. 

  • The final, positional argument is just the name of the image created in the previous section.

 

 

 



 

 

Info

...