You just need the docker and docker-compose packages. You make a docker-compose.yml
file and there you define all settings for the container (image, ports, volumes, …). Then you run docker-compose up -d
in the directory where that file is located and it will automatically create the docker container and run it with the settings you defined. If you make changes to the file and run the command again, it will update the container to use the new settings. In this command docker-compose
is just the software that allows you to do all this with the docker-compose.yml
file, up
means it’s bringing the container up (which means starting it) and -d
is for detached, so it does that in the background (it will still tell you in the terminal what it’s doing while creating the container).
Comment on What's the deal with Docker?
AlexPewMaster@lemmy.zip 10 months agoThis docker compose up -d
thing is something I don’t understand at all. What exactly does it do? A lot of README.md files from git repos include this command for Docker deployment. And another question: How can you automatically start the Docker container? Do you need a systemd service to run docker compose up -d
?
Fisch@discuss.tchncs.de 10 months ago
hperrin@lemmy.world 10 months ago
Docker Compose is basically designed to bring up a tech stack on one machine. So rather than having an Apache machine, a MySQL machine, and a Redis machine, you set up a Docker Compose file with all of those services. It’s easier than using individual Docker commands too. It sets up a network so they can all talk to each other, then opens the ports you tell it to. So you can basically isolate a bunch of services with their own tech stacks all on the same machine. I’ve got my Jellyfin server running on the same machine as my Mastodon instance, thanks to Docker Compose.
As long as Docker is configured to run automatically at boot (which it usually is when you install it), it will bring containers back up that are set to be restarted. You can use the “always” or the “unless-stopped” values for the restart option, depending on your needs, then Docker will bring that container back up after a reboot.
Docker Compose is also useful in this context, because you can define dependencies for services. So I can say that the Mastodon container depends on the Postgres container, and Docker Compose will always start the Postgres container first.