Using Containers to Connect Your Go Code to Other Components
Introduction and Motivations
If you’re just starting out with containers, you might be finding it all a bit confusing. Learning about containers is a bit like learning about Linux or about Go—it’s potentially a huge topic! But everyone has to begin somewhere.
This lesson will show you how to use containers to connect your Go code to components on your local development machine, regardless of whether that code is running in a container.
Example Code
The easiest way to download the example code for this lesson is by using the go get
command, as demonstrated here:
$ go get github.com/lizrice/hello-container-world/...
Using Docker
If you’re diving into this lesson, you probably already have Docker installed, but if not, there are good instructions available for installing it and verifying that everything is set up correctly. After you’ve done that, you’ll be ready to work through the examples in this lesson.
Note
Docker 1.13 reorganized the command-line interface (CLI) to refer to objects (e.g., docker image build
instead of docker build
). As of this writing, the older versions work as aliases, but it is more future-proof to become accustomed to the new style.
What Is a Container?
Let’s recap as to what containers are: containers make it possible for you to isolate an application such that the application performs as if it were running on its own private machine, regardless of the actual environment in which it’s ...
Get Using Containers to Connect Your Go Code to Other Components now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.