Hey everyone! I'm just starting out with Docker on Ubuntu, and I have a question about using .sh files. After I run my jellyfin.sh script to launch a Docker container, I sometimes need to make changes—like adding mounts. However, when I edit the .sh file and try to run it again, I get an error because the container already exists with the name 'jellyfin'. Can someone explain the proper way to edit my .sh file and rerun it so the changes take effect? Here's a glimpse of my current setup: I run the script using `sudo ./jellyfin.sh`, but I'd like to understand what to do after saving my edits to avoid the conflict. Thanks for your help!
2 Answers
The issue you're running into is that once you start a Docker container with a specific name, like 'jellyfin', you can't just run it again without stopping and removing the existing one first. You can do that with the commands `docker container stop jellyfin` and `docker container rm jellyfin`. After those commands, running your script again should work fine. Also, learning the basics of Docker is really worth it! It’ll save you a lot of headaches down the road.
Honestly, running Docker commands through a bash script like that isn’t the best way to manage containers. Once you create a container, you need to stop and remove it to recreate it with the same name. I highly recommend switching to Docker Compose. It makes things so much easier; you just edit the YAML file and run `docker compose up -d` to update your services automatically!
Thanks for the suggestion! I’ll definitely look into Docker Compose. Sounds like it could save me time.