Nono.MA

NOVEMBER 9, 2022


How to use TensorFlow inside of a Docker container.


See transcript ›

JUNE 10, 2022

For a Docker container started with the docker run command to be removed when it exits, you need to use the --rm flag.

docker run -it --rm ubuntu /bin/bash

JUNE 9, 2022

"The following command runs an ubuntu container, attaches interactively to your local command-line session, and runs /bin/bash," reads the official Docker starter guide.

docker run -it ubuntu /bin/bash

Inspecting the Linux virtual machine

docker run -it ubuntu /bin/bash

# List files inside of the Docker container
root@642064598df6:/ ls
# bin   dev  home  lib32  libx32  mnt  proc  run   srv  tmp  var
# boot  etc  lib   lib64  media   opt  root  sbin  sys  usr

# Print the current directory
root@642064598df6:/ pwd
# /

# Exit the instance
root@642064598df6:/ exit
# exit

Behind the scenes

Here's a summary from Docker's docs.

When you run this command, the following happens (assuming you are using the default registry configuration):

  • If you don't have the ubuntu image locally, Docker pulls it from your configured registry (as if you had run docker pull ubuntu).
  • Docker creates a new container (as if you had run a docker container create command manually).
  • Docker allocates a read-write filesystem to the container as its final layer. This allows a running container to create or modify files and directories in its local filesystem.
  • Docker creates a network interface to connect the container to the default network, since you did not specify any networking options. This includes assigning an IP address to the container. By default, containers can connect to external networks using the host machine's network connection.
  • Docker starts the container and executes /bin/bash. Because the container is running interactively and attached to your terminal (due to the -i and -t flags), you can provide input using your keyboard while the output is logged to your terminal.

When you type exit to terminate the /bin/bash command, the container stops but is not removed. You can start it again or remove it.

Read the Docker overview guide.

Remove the container on exit

If you don't want your container to persist after you exit, you should use the --rm flag.

docker run -it --rm ubuntu /bin/bash

JUNE 30, 2021

I get this error after running docker run --rm -it IMAGE_TAG.

The problem was that the image I was using wasn't really an image to execute in Docker but a set of steps to build a Python wheel package (.whl).

The solution was to only build the image specifying an --output directory to which the resulting wheel file could be copied.

DOCKER_BUILDKIT=1 docker build --output folder_to_save_wheel .

JANUARY 20, 2021

Supposing you've started your container with ./docker-wine wine notepad and saved your files to your volume, for instance, at My Music folder with the new.txt name.

docker cp wine:/home/wineuser/new.txt ~/Desktop/

Want to see older publications? Visit the archive.

Listen to Getting Simple .