Versions Compared

Key

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

...

Code Block
languagebash
themeMidnight
titleShow docker images/processes
linenumberstrue
collapsetrue
# Get a list of all the docker images
docker images 
# or
docker image list 

# To view a list of docker processes
docker ps

...

Code Block
linenumbers
languagebash
themeMidnight
titleThe Dockerfile - Building an image
truecollapsetrue
# Use the latest tf GPU image as parent. This operation is analogous to inheritance in OOP. 
# The image ships with tensorlfow-gpu and jupyter installed for python 2. It is also  
# configured so that a jupyter server will be launched at container startup. Note that you 
# don't have to use this image as parent. 
FROM tensorflow/tensorflow:latest-gpu 

# Set working directory for container 
WORKDIR /app  

# Make ssh directory (useful for adding ssh keys later) 
RUN mkdir -p /root/.ssh 

# Update repositories 
RUN apt-get update 

# Install git  
RUN apt-get install git -y 

# Install pip3 (parent image only comes with python2 stuff) 
RUN apt-get install python3-pip -y 

# Install your python packages  
RUN pip3 install --upgrade pip 
RUN pip3 install numpy 

# Add more pip installs here. Alternatively move everything to a dedicated requirements file.

...

Code Block
languagebash
themeMidnight
titleBuild image
linenumberstrue
collapsetrue
mkdir ~/docker/myproject 
mv Dockerfile ~/docker/myproject/Dockerfile

...

Then change working directory to the newly created folder and build the image:

 

 

 

Code Block
languagebash
themeMidnight
titleChange working directory and build image
collapsetrue
cd ~/docker/myproject 

docker build -t <image_name> . 

...