Docker Container
Install Docker
Download installation script:
curl -fsSL https://get.docker.com -o get-docker.sh
Run script with root privileges:
sudo sh get-docker.sh
Add the pi user to the docker group:
sudo usermod -aG docker pi
For the group change to work, you have to log out and log in again.
Check if the installation worked:
docker ps
Run the hello-world
test container:
docker run hello-world
Result:
pi@raspberrypi:~ $ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1eda109e4da: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(arm32v7)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
pi@raspberrypi:~ $
Building a docker image:
mkdir docker-test && cd docker-test
nano Dockerfile
Insert the following into the Dockerfile and save:
FROM ubuntu
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get install -y screenfetch
ENTRYPOINT ["/usr/bin/screenfetch"]
Create new docker image:
docker build . --tag myimage:test
Result on successful build:
Successfully built 60d9a33b54f6
Successfully tagged myimage:test
Create and run a new container:
docker run myimage:test -E
Result:
pi@raspberrypi:~/docker-test $ docker run myimage:test -E
./+o+- root@384bf84922db
yyyyy- -yyyyyy+ OS: Ubuntu
://+//////-yyyyyyo Kernel: armv7l Linux 4.14.79-v7+
.++ .:/++++++/-.+sss/` Uptime: 4m
.:++o: /++++++++/:--:/- Packages: 112
o:+o+:++.`..```.-/oo+++++/ Shell:
.:+o:+o/. `+sssoo+/ CPU: ARMv7 rev 4 (v7l) @ 4x 1.2GHz
.++/+:+oo+o:` /sssooo. GPU: BCM2708
/+++//+:`oo+o /::--:. RAM: 161MiB / 927MiB
\+/+o+++`o++o ++////.
.++.o+++oo+:` /dddhhh.
.+.o+oo:. `oddhhhh+
\+.++o+o``-````.:ohdhhhhh+
`:o+++ `ohhhhhhhhyo++os:
.o:`.syhhhhhhh/.oo++o`
/osyyyyyyo++ooo+++/
````` +oo+++o\:
`oo++.
pi@raspberrypi:~/docker-test $
Install Docker-Compose:
sudo pip3 install docker-compose