The user with no hat
The user with no hat

Reputation: 10846

Does it make sense to install the runtime on docker?

I'm considering deploying some apps on docker (aws beanstalk being the provider). Going though various resources I've found it's recommended to use a base images, in my case the official golang image but I'm wondering why would you need the runtime installed (i.e. Golang) on the container. Isn't the binary all you should deploy on the docker container?

Upvotes: 1

Views: 173

Answers (2)

errm
errm

Reputation: 67

I prefer to statically compile and then build a minimal container with only the user-space you need, here is an example.

I personally like to build inside the official container and then copy the binary to my deployment container, I inject docker into my build container with something like this

docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):$(which docker)

That way I build my docker container within my build container and just add the binary with a Dockerfile ADD

Upvotes: 0

Not_a_Golfer
Not_a_Golfer

Reputation: 49265

I'm not a docker aficionado but in general, the Go runtime is compiled into your binary, and you don't need anything but that. The Go image includes the SDK, and is not the runtime. It's only useful if you want to build your app in the container. Otherwise you don't need it.

From that image's doc: The most straightforward way to use this image is to use a Go container as both the build and runtime environment.

So maybe it's a Docker pattern to just build your source on the image, or it's just a habit some people have from interpreted languages. Personally when I'm deploying Go applications (not via docker) I build an artifact on a CI machine and that's what I'm deploying, not the source.

Upvotes: 1

Related Questions