Go & Docker: I'm able to run a go web server when using stdlib, when I use custom packages errors occur

Note the code works perfectly fine when I’m running the code on my laptop.

The following two groups of code will run on my laptop. However the second group (which uses my custom package) doesn’t work on Elastic Beanstalk running docker.

  • Docker bridge over IPSec - Connection reset by peer with Tomcat (but not Nginx)
  • How to compose a container from a Image and layer in Docker 1.10
  • Wildfly/Jboss-v10 is not working in cluster mode with docker swarm
  • Docker - Karaf image with Mongo Image
  • Python invoke Docker build command line only one layer is built
  • Docker Machine can ssh but not scp
  • Standard Lib only

    import (
        "net/http"
        "os"
    )
    
    func main() {
        port := os.Getenv("PORT")
        if port == "" {
            port = "3000"
        }
        http.ListenAndServe(":"+port, nil)
    }
    

    Uses Custom Package

    import (
        "os"
    
        "github.com/sim/handlers"
    )
    
    func main() {
        port := os.Getenv("PORT")
        if port == "" {
            port = "3000"
        }
        handlers.ServeAndHandle(port) // wrapper of ListenAndServe
    }
    

    Error Messages:

    Failed to build Docker image aws_beanstalk/staging-app: andlers: exit status 128 [0mtime=”2015-08-14T05:08:17Z” level=”info” msg=”The command [/bin/sh -c go-wrapper download] returned a non-zero code: 1″ . Check snapshot logs for details.

    2015-08-14 01:08:15 UTC-0400 WARN Failed to build Docker image aws_beanstalk/staging-app, retrying…

    cron.yaml

    version: 1
    cron: 
      - name: "task1"
        url: "/scheduled"
        schedule: "* * * * *"
    

  • All my docker containers have the error “Too many open files”
  • Is docker an ephemeral instance?
  • How to configure CouchDB authentication in Docker?
  • Implications of exposing /var/lib/docker over NFS to serve hosts with limited memory
  • Build the Node js app on Docker
  • Docker web terminal
  • One Solution collect form web for “Go & Docker: I'm able to run a go web server when using stdlib, when I use custom packages errors occur”

    You need a Dockerfile or/and Dockerrun.aws.json for your environment as per the documentation

    Dockerfile

    FROM FROM golang:1.3-onbuild
    
    EXPOSE 3000
    
    CMD ["go run <your.go.file>"]
    

    Dockerrun.aws.json

    {
      "AWSEBDockerrunVersion": "1",
      "Image": {
        "Name": "golang:1.3-onbuild",   # <-- don't need this if you are using a Dockerfile
        "Update": "true"
      },
      "Ports": [
        {
          "ContainerPort": "3000"
        }
      ],
      "Logging": "/var/log/go"
    }
    

    Using the eb command line to deploy ?

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