1

I am trying to run the beego application using docker with the help of docker-compose. I am able access the demo application in http://localhost:8081 URL after running docker-compose up.

docker-compose.yml

version: "2"

services:
  app:
    build: .
    volumes:
      - .:/go/src/hello
    ports:
      - "8080:8080"
    working_dir: /go/src/hello
    command: bee run

Dockerfile

FROM golang:1.10

## Install beego and the bee dev tool
RUN go get github.com/astaxie/beego && go get github.com/beego/bee

app.conf from beego framework

appname = hello
httpport = 8081
runmode = dev

How can I overwrite the httpport(8081) in app.conf using ports(8080) number used in app from docker-compose.yml. After running docker-compose up application runs in port 8081 not in 8080. How can I solve this?

Sathishkumar Rakkiyasamy
  • 3,509
  • 2
  • 30
  • 34
  • I don't follow. What's stopping you from simply editing app.conf? – Peter Mar 21 '18 at 07:04
  • @Peter I don't have any problem in editing app.conf file. In PHP frameworks(Laravel) it is possible to overwrite the port in ENV file using docker-compose environment variables. So only I asked for similar setup is possible or not in beego? – Sathishkumar Rakkiyasamy Mar 21 '18 at 07:16
  • 2
    To read port from env varialbles you probably should use `beego.AppConfig.Set(key, val string)` method and check if proper env variable is set and get it from `os.Getenv`. But why you wanna run it on different port inside docker? If u just wanna get access to it on different port outside (because of allready used port) you should change in you docker-compose file ports section to `"8081:8080"` then you can access your app on `8081` port – ttomalak Mar 21 '18 at 08:12

1 Answers1

1

You shouldn't need to update the app.conf to 8080 use the ports to have the docker container listen on 8081 and respond to 8080.

Change - "8080:8080" to - "8080:8081"

First port is what the docker container will respond to and the second port is the port of the application within the container.

eodgooch
  • 1,322
  • 1
  • 11
  • 17