You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Cluxter <co...@cluxter.email> on 2019/11/11 17:32:08 UTC

Re: Extending CouchDB Docker image

Hi Aurélien,

It looks like you haven't mapped the port 5984 between your host and the
container (also called: publishing the port).

The Dockerfile of the CouchDB Docker image:
https://github.com/apache/couchdb-docker/blob/master/2.3.1/Dockerfile
exposes ports 5984, 4369 and 9100.

According to the Docker documentation here:
https://docs.docker.com/engine/reference/builder/

"The EXPOSE instruction does not actually publish the port. It functions as
a type of documentation between the person who builds the image and the
person who runs the container, about which ports are intended to be
published. To actually publish the port when running the container, use the
-p flag on docker run to publish and map one or more ports, or the -P flag
to publish all exposed ports and map them to high-order ports."

So did you publish the port when you instantiated the container?

Basically, the container can be seen as a virtual machine (even if it's not
from a technical perspective) which is in a virtual LAN (a Docker LAN, see
Docker Networks for more info) sitting behind a NAT. So when you want to
access a machine on this LAN, you have to map the port between the LAN and
the rest of the world (your host), as you would do it with any other NAT.

Let me know how that went out or if you need more info.

Kind regards,

Baptiste REBILLARD


Le jeu. 22 août 2019 à 17:35, Aurélien Bénel <au...@utt.fr> a
écrit :

> Hi everyone,
>
> I’m currently trying to benefit from the dockerization of CouchDB (thanks
> for this, BTW!).
> My aim would be to dockerize also our own applications that are based on
> CouchDB.
> Does any of you have similar experience?
>
>
> I read in documentation that for custom configurations there are already
> known solutions
> (runtime bind-mount, docker configs or extending Dockerfile with a COPY).
>
> What is still not clear to me is how to extend CouchDB docker image to
> include preset databases
> (with design documents and optionally initial data).
> In my future Dockerfiles, I will probably use couchapp python tool (for
> compatibility with our existing code),
> but for now I am trying the simplest thing as possible: just creating a
> database with curl.
>
> I wrote the following Dockerfile:
>
>     FROM couchdb
>     RUN curl -X PUT localhost:5984/db
>
> And when I launched the build:
>
>     docker build .
>
> I got:
>
>     curl: (7) Failed to connect to localhost port 5984: Connection refused
>
> I then thought that the service might be not be ready. Hence I tried to
> add a timeout on curl but in vain.
> Any idea of why this doesn’t work or about what I should test instead?
>
>
> Regards,
>
> Aurélien
>
>
>

Re: Extending CouchDB Docker image

Posted by Aurélien Bénel <au...@utt.fr>.
Thank you Baptiste for your answer.
However my problem was not ports publishing.

My question was finally answered on StackOverflow:
https://stackoverflow.com/questions/57660451/extending-couchdb-docker-image

It seems that what I was trying to do was not possible: 
	Couchapps are data from CouchDB perspective.
	Therefore they are stored in Docker volumes.
	Therefore couchapps cannot be part of an extended Docker image.

I changed my strategy and used DockerCompose to integrate CouchDB and my couchapps:
https://github.com/Hypertopic/Argos/blob/v4/docker-compose.yml


Regards,

Aurélien



> Le 11 nov. 2019 à 18:32, Cluxter <co...@cluxter.email> a écrit :
> 
> Hi Aurélien,
> 
> It looks like you haven't mapped the port 5984 between your host and the
> container (also called: publishing the port).
> 
> The Dockerfile of the CouchDB Docker image:
> https://github.com/apache/couchdb-docker/blob/master/2.3.1/Dockerfile
> exposes ports 5984, 4369 and 9100.
> 
> According to the Docker documentation here:
> https://docs.docker.com/engine/reference/builder/
> 
> "The EXPOSE instruction does not actually publish the port. It functions as
> a type of documentation between the person who builds the image and the
> person who runs the container, about which ports are intended to be
> published. To actually publish the port when running the container, use the
> -p flag on docker run to publish and map one or more ports, or the -P flag
> to publish all exposed ports and map them to high-order ports."
> 
> So did you publish the port when you instantiated the container?
> 
> Basically, the container can be seen as a virtual machine (even if it's not
> from a technical perspective) which is in a virtual LAN (a Docker LAN, see
> Docker Networks for more info) sitting behind a NAT. So when you want to
> access a machine on this LAN, you have to map the port between the LAN and
> the rest of the world (your host), as you would do it with any other NAT.
> 
> Let me know how that went out or if you need more info.
> 
> Kind regards,
> 
> Baptiste REBILLARD
> 
> 
> Le jeu. 22 août 2019 à 17:35, Aurélien Bénel <au...@utt.fr> a
> écrit :
> 
>> Hi everyone,
>> 
>> I’m currently trying to benefit from the dockerization of CouchDB (thanks
>> for this, BTW!).
>> My aim would be to dockerize also our own applications that are based on
>> CouchDB.
>> Does any of you have similar experience?
>> 
>> 
>> I read in documentation that for custom configurations there are already
>> known solutions
>> (runtime bind-mount, docker configs or extending Dockerfile with a COPY).
>> 
>> What is still not clear to me is how to extend CouchDB docker image to
>> include preset databases
>> (with design documents and optionally initial data).
>> In my future Dockerfiles, I will probably use couchapp python tool (for
>> compatibility with our existing code),
>> but for now I am trying the simplest thing as possible: just creating a
>> database with curl.
>> 
>> I wrote the following Dockerfile:
>> 
>>    FROM couchdb
>>    RUN curl -X PUT localhost:5984/db
>> 
>> And when I launched the build:
>> 
>>    docker build .
>> 
>> I got:
>> 
>>    curl: (7) Failed to connect to localhost port 5984: Connection refused
>> 
>> I then thought that the service might be not be ready. Hence I tried to
>> add a timeout on curl but in vain.
>> Any idea of why this doesn’t work or about what I should test instead?
>> 
>> 
>> Regards,
>> 
>> Aurélien