The Docker container

In this case, we will set up the leanest container we can to house our code:

FROM base_image

RUN apt install -y python3-pydot python-pydot-ng graphviz

ADD . /

Each line is easy to break down. First, we inherit from our base_image we developed in Chapter 2Data First, Easy Environment, and Data Prep, with the following:

FROM base_image

Next, we install one of the most handy tools in Python development—IPython:

RUN apt install -y python3-pydot python-pydot-ng graphviz ipython

IPython allows you to drop down to a shell in the middle of any Python code. If you are having trouble understanding an issue with your Python code, I suggest using IPython to help troubleshoot. If you want an interactive console at a particular line in your code, simply add the following line:

from IPython import embed; embed()

This will open an interactive shell at that line. Finally, let's add all of the files in the current directory into the root directory of the container:

ADD . /

It is possible to specify specific files, but with the dot (.), we are telling Docker to add all of the files into the root directory of the container.

All three of these lines should be added into a file called Dockerfile in a folder called full-gan. Your directory structure should look like this when you are done:

full-gan/
└── Dockerfile
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.139.168