Then closed terminal and a day later I reopened terminal and ran the command above again, but this time I get an error:
docker: Error response from daemon: Conflict. The container name "/postgres" is already in use by container "945bd087501137a418eb8e0a7c7665fb2b7bb8c37e2afe22bf52e1200e89735e". You have to remove (or rename) that container to be able to reuse that name.
What does that mean? I’m not sure what to do next, is it ok to remove the container (how)?
Additionally, when I run xcode, I get this runtime error:
It basically means that there is already a container called postgres running so it can’t create another one with that name. If you run docker ps -a you can see all your containers. Since you already have the container started, you have a few options:
start the container that is already created with - docker start postgres
delete the old container before trying to start it again - docker rm postgres. This is also a useful command if you want to reset your DB
The second error from Xcode basically says that it can’t connect to the DB on localhost:5432 - because the created Docker container is not started.
But does it mean that every time I close Terminal, I have to delete the container with docker rm postgres? I’ll have to reboot my computer at some point
The useful commands have been added to the second edition of the book! Does it definitely stop when you close the terminal? If you’re passing the -d flag it should stay alive.
You shouldn’t need to remove the container and start again when restarting your computer, you should just need to do docker start postgres and be good to go.
I am using the -d flag, as shown in my original post. (I am copy pasting from the book to Terminal). However, it does NOT stay alive. I get this error again:
docker: Error response from daemon: Conflict. The container name "/postgres" is already in use by container "3bb129804d7ae62364fa128123df388afa7cc41149dbfafb8bbbaae02d29200d". You have to remove (or rename) that container to be able to reuse that name.
Running docker start postgres doesn’t seem to do anything.