0

i have a tricky problem for a while with the new swarm mode.

I simply try to run a go web server in the first and a mongo db in the second container. Therefor I am using a private test image and the standard mongo image. Calling the mongo service on port 27017 works. The go run main.go command runs in the test service. I Expose: 8080 in the Dockerfile. Additionally ports: "4444:8080" is set for the go service (users, test image).

Dockerfile:

  1 FROM crypvert-base:latest
  2 
  3 ADD . /go/src/test
  4 WORKDIR /go/src/test
  5 
  6 RUN go get -d -v
  7 RUN go install test
  8 ENTRYPOINT /go/bin/test
  9 
 10 EXPOSE 8080

docker-stack.yml

  1 version: "3"
  2 
  3 services:
  4     users:
  5         image: test:latest
  6         ports:
  7             - "4444:8080"
  8         depends_on:
  9             - mongo
 10     mongo:
 11         image: mongo:latest

users/bootstrap.go

  8 func Bootstrap() {
 10     e := echo.New()
 19     e.Logger.Fatal(e.Start(":8080"))
 20 }

$ docker service inspect --pretty test_users

ID:     o9wz4b17bew1s66ixy0i231uu
Name:       test_users
Labels:
 com.docker.stack.namespace=test
Service Mode:   Replicated
 Replicas:  1
Placement:
ContainerSpec:
 Image:     test:latest
Resources:
Networks: kd7q422w06quendlh8xkz7r6o 
Endpoint Mode:  vip
Ports:
 PublishedPort 4444
  Protocol = tcp
  TargetPort = 8080 
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
nayD93
  • 13
  • 2

0 Answers0