What is the working directory of a Docker Golang application?

When I serve a Golang Application from within the official Docker Hub Repository I wonder what will be the default working directory the application starts up?

Background: I will have to map local Certificate Authority and server keys into the container to serve TLS https and I wonder where to map them to the application will be able to grab them in current working directory of the application from within the container?

  • Docker Mysql (Hibernate) Connection
  • Terraform and docker networking
  • Docker registry 2.0 API v2
  • Sidekiq jobs aren't firing in development mode, only in production
  • Using Ansible docker_container, how can I display standard out? (stdout)
  • Can several nodes access mounted docker containers
  • Return code of a bash script being called from a Subprocess
  • Docker/Rails - Permission denied @ dir_s_mkdir Errno::EACCESS
  • Creating a Docker UAT/Production image
  • Docker - Could not load X509 key pair
  • Delete files in offline docker container
  • Access VMware Host from docker container java app
  • 2 Solutions collect form web for “What is the working directory of a Docker Golang application?”

    If you are using the golang:1.X-onbuild image from DockerHub will be copied into(https://hub.docker.com/_/golang/)


    this means all files and directories from the directory where you run the

    docker build 

    command will be copied into the container.

    And the workdir of all images is


    Go will return the current working directory using

    currdir, _ = filepath.Abs(filepath.Dir(os.Args[0]))

    Executed within a golang container and right after startup, the pwd is set to


    The current working directory of a golang application starting up within a Docker container is thus /go/src/app. In order to map a file/directory into a container you will habe to use the -v-switch as described in the Documentation for run:

    -v /local/file.pem:/go/src/app/file.pem

    Will map a local file into the pwd of the dockerized golang app.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.