Intro to Docker (by installing Grocy)
Problem
I’ve heard a lot about Docker, but never had the time to properly explore it. I also recently found a new application I’d like to host on my home network, grocy, which has a docker container you can use to run it. What better time than the present to learn?
Materials
I’m hosting this on my raspberry Pi 3b along with the rest of my home networking setup. For this I’ll assume you’ve already got your pi set up, or some other debian linux host.
Benefits
From my understanding, these are the key benefits to using Docker
- Dependency management
- Isolation of instances
- Security
- Ease of use
Guide
Installing Docker
Installing docker was relitivly straightforward. You can find the official docs on how to do it here, but I’ll summarize below:
- Add Docker’s GPG key to install securely
1 2 3 4 5 6
# Add Docker's official GPG key: sudo apt-get update sudo apt-get install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc
- Add the repository to apt sources:
1 2 3 4 5
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update
- Install the latest version with
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin - Test the install by running
sudo docker run hello-world
Running the Grocy Image
This information is summarized from the grocy docker page, which I found a little confusing to follow. I opted not to use docker-compose.
- First install the image using
sudo docker pull linuxserver/grocy - Next, create a config directory (I created one at ~/docker/grocy/config)
- Run the container with the following command. You can read about the options we’re using in the docker docs. You can also change the timezone by picking one from this list.
1
2
3
4
5
6
7
8
9
docker run -d \
--name=grocy \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=US/Eastern \
-p 9283:80 \
-v /home/<username>/docker/grocy/config:/config \
--restart always \
lscr.io/linuxserver/grocy:latest
If you cannot run these commands without sudo, you can add the current user to the docker group on the system with teh following commands:
1 2 3 sudo groupadd -f docker sudo usermod -aG docker $USER newgrp dockerThen running
groupsshould have ‘docker’ show in the list, allowing you to run docker commands without sudo.
- If you run into issues and must remove the container, you can do so with
docker container rm /grocy - You can confirm the container is running with
docker container ps. You should see the new container in your list. - Once it’s running, attemt to access grocy from your network. This can be done by browsing to
:9283/login to be presented with a login page. The default login for grocy is admin/admin
That’s it! It really was that simple to get grocy up and running. Including the initial docker install and some snafews I ran into (like adding the wrong apt repository), it took in total under 2 hours. Now it’s time to play around with grocy itself, but that may be a blog for another day.