How to store data in external drive with Docker Postgres:9.3 image?

0 votes

I want to setup my database inside a container using the Postgres:9.3 docker image, however I want to store my data in external drive.

I attempted it using the command

`docker run -dit -p 5432:5432 -v /mnt/external/docker_volume:/var/lib/postgresql/data --name mydatabase postgres:9.3`

Container got created as it echoes the container id, but it is not shown as running from docker ps. The above command works for other images. The images has VOLUME defined in its dockerfile but I haven't figure out a way to get around it.  Can somebody help me?

Jul 12, 2018 in Docker by Nilesh
• 6,920 points
229 views

1 answer to this question.

0 votes
Apparently, the problem would be in your  /mnt/external/docker_volume. It was not empty and the Postgres init script didn't like it. Found this out after running with -it option and saw the output in terminal.
answered Jul 12, 2018 by Kalgi
• 2,620 points

Related Questions In Docker

0 votes
1 answer
0 votes
1 answer

How to run an image with volume on docker for windows?

Try : declaring the volume of container mounting the ...READ MORE

answered Sep 19, 2018 in Docker by Tyrion anex
• 8,310 points
58 views
0 votes
1 answer

How to Backup, Restore or Migrate data volumes in a docker container?

Steps to Backup a container 1)     ...READ MORE

answered Jul 3 in Docker by Sirajul
• 41,000 points
606 views
+1 vote
11 answers

How to run multiple commands in docker at once?

Try this: docker run image bash -c "cd ...READ MORE

answered Apr 17 in Docker by anonymous

edited Apr 17 by Kalgi 28,113 views
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 57,300 points
270 views
0 votes
1 answer

How to deal with persistent storage (e.g. databases) in docker

For Docker 1.9.0 and above, Use volume API docker ...READ MORE

answered Jul 18, 2018 in Docker by Kalgi
• 2,620 points
81 views
0 votes
1 answer

How to remove old Docker containers

There is a new feature in Docker 1.13.x called Docker ...READ MORE

answered Jul 18, 2018 in Docker by Kalgi
• 2,620 points
48 views