Skip to content

Instantly share code, notes, and snippets.

@abbas-v1
Created June 25, 2019 12:30
Show Gist options
  • Save abbas-v1/e3d4d099878bbbfe66ffff8d32a7cff2 to your computer and use it in GitHub Desktop.
Save abbas-v1/e3d4d099878bbbfe66ffff8d32a7cff2 to your computer and use it in GitHub Desktop.
Create a database image from a container
docker run -p 5432:5432 --name some-postgres -e PGDATA=/var/lib/postgresql/pgdata -e POSTGRES_PASSWORD=MyPa@@W0rd -d postgres
populate the database ...
docker commit some-postgres myAccount/repo-name:1.0
make sure the data is now persisted in the new image
docker run -p 5432:5432 --name persistent-postgres -d myAccount/repo-name:1.0
docker login -u myAccount
docker push myAccount/repo-name:1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment