Search code examples
dockercontainerscouchdb

How to make docker container open to its host


machine info: nectar virtual machine instance
The operating system: Ubuntu 20.04 LTS (Focal) amd64
security group: default + ssh + http
docker image info: ibmcom/couchdb3:3.1.1
command line typed and output:

command:
docker pull ibmcom/couchdb3:${VERSION} where version is set equal 3.1.1
output:

3.1.1: Pulling from ibmcom/couchdb3
Digest: sha256:784a43d1acd4cfa78a5fb4992a2d7a6aecec03d1b6a6458f443399abb8f38902
Status: Image is up to date for ibmcom/couchdb3:3.1.1
docker.io/ibmcom/couchdb3:3.1.1
root@yingrui1:/home/ubuntu#

command:

root@yingrui1:/home/ubuntu# docker create\
      --name couchdb${node}\
      --env COUCHDB_USER=${user}\
      --env COUCHDB_PASSWORD=${pass}\
      --env COUCHDB_SECRET=${cookie}\
      --env ERL_FLAGS="-setcookie \"${cookie}\" -name \"couchdb@${node}\""\
      ibmcom/couchdb3:${VERSION} --network host -p 8080:5984

where "node is a ip address

output:
afe973a0515cb8d4a7acf13bcdf019f7b6029dcf291c449f0a2a1772f6c80234

command:
docker start [email protected] Note the "[email protected]" is the container I just created
output:
some long string

command:
docker ps output:

CONTAINER ID   IMAGE                   COMMAND                  CREATED          STATUS         PORTS                          NAMES
04aaabb201f1   ibmcom/couchdb3:3.1.1   "/docker-entrypoint.…"   22 seconds ago   Up 3 seconds   4369/tcp, 5984/tcp, 9100/tcp   couchdb172.17.0.2

If I understand correctly, you need the ports shows the mapping like "4369->0.0.0.0" something. The current ports info shows it is not open its port to the host. So I wonder how can you do it? I have try expose and -P as well but neither of them works, I am really desperate now, any help will be appreciate.


Solution

  • As @David Maze pointed out, the problem is I should move the -p before the image name. What a silly mistake!