Baby's 1st Steps
Let's Learn Docker
WordsPhil cominglikes soon.Docker Watchand it's something useful to learn. And LastPass is taking away my free service so I need to DIY a password manager. Here's some notes
References
Bitwardenrs as the jumping off point
Bitwarden basic commands - Imperative vs Declarative
Let's use this spacecommand to install bitwardenrs but also as a way to learn basic docker stuff
sudo docker run -d --name bitwarden -v ~/bwdata/:/data/ --restart=always -p 80:80 bitwardenrs/server:latest
-
docker
= command like sudo -
run
= verb - it provides actions and creates the container by downloading an image and then tries to start it. docker has command options so the -X options. For example the -zavh options you specified in rsync -
-p 8999:80
= port map from container (docker)to the host (server aka rpi). so 8999 is my IRL port that is on my network. I'd port forward it on the router if i wanted to expose the service to the actual internet. I don't have to do this. 80 is the port the container thinks it's seeing. -
-v urhostfolder:urcontainerfolder
= volume mount aka what folders are you using. Like the port map, you setup a folder path location in the host (~/docker
for example) and then a folder path location for in the new container. -
restart=always
= this sets it so the container restarts whenever it goes down. Could be because of power outage, restarting the server, etc.- If I want to stop the container myself, I'd run
docker stop
- If I want to stop the container myself, I'd run
-
--name bitwarden
= this is the name of hte container. it's there for me to reference later -
:latest
= this specifies the version of the image I'm looking for. in this case, i want the latest bitwardenrs
So I could run docker with all these options but there's another way. Above is the imperative way of running docker. So I'm telling docker EXACTLY what I want it to do. I could also run things declarative. So I could tell docker what I'd like it to do and have docker fill in the details. See this link for more info. So think C vs Python. That terminology is lifted from programming I guess.
Let's try it again but now using docker-compose
.
- Install docker-compose
- For normal people:
sudo curl -L "https://github.com/docker/compose/releases/download/1.28.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- For RPi:
sudo curl -L --fail https://raw.githubusercontent.com/linuxserver/docker-docker-compose/master/run.sh -o /usr/local/bin/docker-compose
- For normal people:
- Create a docker-compose.yaml in
/usr/local/bin/docker-compose
- In my case I'd be setting up for bitwarden. Put this in the folder you've setup for all docker info to live. for me it's ~/docker
services:
bitwarden:
image: bitwardenrs/server:latest
volumes:
- <hostfolder>:<containerfolder>
ports:
- "8999:80"
- Run
docker-compose up -d
in/usr/local/bin/docker-compose
- Hopefully you did the thing! In my case, I have bitwarden up on
<ur-rpi-ip-here>:8999
. If you install and run docker on the same machine (I'm running it through my server), then you could uselocalhost/#/