0

So, I pulled the postgres image down from docker. I followed a tutorial which explained what's going with the command below and the the whole docker pull. I can log in to the instance fine. But when I restart my computer or shutdown docker I end up goign through similar setup steps and am not able to access the postgres instance anymore. Can someone explain what's going on here:

  1. Run this command docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d postgres -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres

  2. log in via PG admin.

Nothing, instance not available.

So, I feel like I am missing a step at one point I had executed a command like this: docker exec -it c5b8bdd0820b35a01ea153a44e82458a6285cf484b701b2b2d6d4210266fb4f8 bash

which gave me acess to the shell for the image, after doing that I was able then to use PGAdmin, however, I feel like that may have been coincidence? As this does not work currently.

So, what am I doing wrong? What's an easier way to do this?

1 Answer 1

1

The --rm causes Docker to automatically remove the container when it exits. Remove it. You can also add --restart always and your container will be up after restart.

Sign up to request clarification or add additional context in comments.

1 Comment

Okay, thank you so much! I thought the -rm just removed it after I stopped the container

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.