Hands-on Docker

End-to-end practical tutorial to start using Docker

Photo by amanda panda on Unsplash

Theoretical stuff

Photo by Guillaume Bolduc on Unsplash
Source: own elaboration
Source: own elaboration

Practical stuff

FROM ubuntu:16.04
RUN apt-get update &&\
apt-get install -y python3 &&\
apt-get install -y python3-pip &&\
python3 -m pip install -U pip
COPY requirements.txt /opt/app/requirements.txt
WORKDIR /opt/app
RUN pip install -r requirements.txt
pandas==0.24.2numpy==1.16.4
mylaptop:~mypath/docker$ docker build .
mylaptop:~mypath/docker$ docker build -t coolimage:1.0 .
$ docker run -ti -v/home/victor/tutorials/ml:/container_ml --name happyhippo coolimage:1.0
root@46d5e125776f:/container_ml# python3 script.py
Source: own elaboration

Nice Tricks

# list all images (including intermediate images)
docker image ls -a
# list all containers
docker container ls -a
# list running containers
docker container ls
# remove specific image
docker image rm IMAGE_ID
# remove specific container
docker rm CONTAINER_ID
# remove all unused images
docker image prune
# remove all stopped containers
docker container prune
docker container ls -a
docker start happyhippo
docker attach happyhippo
# information about container
docker inspect CONTAINER_ID
# information about image
docker inspect IMAGE_ID

Conclusion

References

Love AI, reading, climbing and meditation.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store