2

I want to create a Docker image which contains Java and PostgreSQL. I just want to create an Image to reuse it from anywhere.

From reading the documentation I don't understand how I can do that.

This is what I tried:

user@host:/$ docker run -i -t debian /bin/bash 
root@container:/$ apt-get install postgresql-9.3
user@host:/$ docker ps 
user@host:/$ docker commit <CID> username/postgresql
9
  • 1
    docs.docker.com/userguide/dockerrepos and docs.docker.com/userguide/dockerimages — you may want to be more specific about what you've tried and where you got stuck. This is all fairly well documented.
    – slhck
    Commented Feb 12, 2015 at 8:17
  • I have seen these docs but I am not clear about how to make my own image and push it into Repo?
    – SOP
    Commented Feb 12, 2015 at 8:37
  • 1
    There is a specific guide on creating our own images. And pushing to a hub is also explained. You need to tell us what specifically you don't understand or at which point you got stuck. Right now every answer would just point you to the documentation again.
    – slhck
    Commented Feb 12, 2015 at 8:52
  • @slhck : I want to create my own Image which contains Java + Postgresql and I am not getting it from the document. I just want to create an Image to reuse it from anywhere.
    – SOP
    Commented Feb 12, 2015 at 8:58
  • 1
    Create a Base Image maybe?
    – slhck
    Commented Feb 12, 2015 at 9:00

2 Answers 2

0

Use a Dockerfile:

FROM debian
RUN apt-get install postgresql-9.3

Then build it with:

docker built -t username/imagename .
-1

I would use Travis R's approach, with using a dockerfile. If you absolutely want to do it your way, what you should do after the commands you have already typed in is:

user@host:/$ docker images

Which should now list something like

REPOSITORY            TAG    IMAGE ID       CREATED           SIZE
username/postgresql          be6ac83f7606   2 minutes ago     234 MB

This is your docker image that you just created. If you want to start it run

user@host:/$ docker run -[whatever flags you want] username/postgresql 

Be aware that this is not a particulary useful container to start testing with, since it does not contain a database, no data and no way of actually testing. A better approach for testing and playing around would be to use the following guide: https://docs.docker.com/engine/getstarted/step_one/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .