Usually, application containers (this is a general term for docker
, rkt
, and other types of containers) do not have etcdctl
or even curl
installed by default. Installing curl
is much easier than installing etcdctl
.
For our example, we will use the Alpine Linux docker image, which is very small in size and will not take much time to pull from the docker
registry:
Firstly, we need to check the
docker0
interface IP, which we will use withcurl
:$ echo"$(ifconfig docker0 | awk'/\<inet\>/ { print $2}'):2379" 10.1.42.1:2379
Let's run the
docker
container with abash
shell:$ docker run -it alpine ash
We should see something like this in Command Prompt:
/ #
.As
curl
is not installed by default on Alpine Linux, we need to install it:$ apk update&&apk add curl $ curl -L http://10.1.42.1:2379/v2/keys/ {"action":"get","node":{"key":"/","dir":true,"nodes":[{"key":"/coreos.com","dir":true,"modifiedIndex":3,"createdIndex":3}]}}
Repeat steps...