We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Dockerizing the Server

Now that you know how to run your server manually, let's run it in Docker! The steps are simple:

  1. Build the Server
  2. Create a Dockerfile
  3. Build an image using the Dockerfile (which will copy in the built server)
  4. Run the image in a container

Assignment

FROM debian:stable-slim
# COPY source destination
COPY goserver /bin/goserver

Replace the first "goserver" with the name of your server executable if it's different.

The ADD command would also work here, but COPY is fine because we don't need the extra functionality that ADD offers.

CMD ["/bin/goserver"]
docker build . -t goserver:latest
docker run -p 8010:8010 goserver

If you get an exec format error, it's probably because you built the go server for your local architecture, but you're trying to run it on a Linux OS! To fix it, rebuild the binary (and then the Dockerfile) with these environment variables:

GOOS=linux GOARCH=amd64 go build

Run and submit the CLI tests.