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 container ipv6 configuration not working
  • Unable to find image '7111.mithun:latest' locally Error response from daemon: repository 7111.mithun not found: does not exist or no pull access
  • How to add private registry to docker query list?
  • Docker Compose does not bind ports
  • .ebextensions with Docker on elasticbeanstalk
  • Creating a multi node Kubernetes Cluster for a stateless webapp
  • 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: "* * * * *"
    

  • How to use Docker with Tomcat?
  • CoreOS not able to login with provided username and password in cloud-config file?
  • How to start Phoenix by using PostgeSQL through container?
  • Screen within Docker from ssh
  • Docker on OSX with Certificate Authentication Proxy
  • Where to keep dependencies (large files or directory structures) for use with Docker/Docker-Compose?
  • 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.