Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running containers on docker in windows [ERROR] #13247

Closed
brovatten opened this issue Jul 28, 2021 · 9 comments
Closed

Running containers on docker in windows [ERROR] #13247

brovatten opened this issue Jul 28, 2021 · 9 comments

Comments

@brovatten
Copy link

Hi all,

I am newbie to etcd and been stuck on this for weeks and could really use some help.
I want to start a 3-node cluster on windows using docker container. By following the documentation I pasted the following as a batch file:

set REGISTRY=quay.io/coreos/etcd
set REGISTRY=gcr.io/etcd-development/etcd

# For each machine
set ETCD_VERSION=latest
set TOKEN=my-etcd-token
set CLUSTER_STATE=new
set NAME_1=etcd-node-0
set NAME_2=etcd-node-1
set NAME_3=etcd-node-2
set HOST_1=10.20.30.1
set HOST_2=10.20.30.2
set HOST_3=10.20.30.3
set CLUSTER=%NAME_1%="http://%HOST_1%:2380",%NAME_2%="http://%HOST_2%:2380",%NAME_3%="http://%HOST_3%:2380"
set DATA_DIR =/var/lib/etcd


set THIS_NAME=%NAME_1%
set THIS_IP=%HOST_1%
docker run ^
  -p 2379:2379 ^
  -p 2380:2380 ^
  --name etcd %REGISTRY%:%ETCD_VERSION% ^
  /usr/local/bin/etcd ^
  --data-dir=/etcd-data --name %THIS_NAME% ^
  --initial-advertise-peer-urls "http://%THIS_IP%:2380" --listen-peer-urls "http://0.0.0.0:2380" ^
  --advertise-client-urls "http://%THIS_IP%:2379" --listen-client-urls "http://0.0.0.0:2379" ^
  --initial-cluster %CLUSTER% ^
  --initial-cluster-state %CLUSTER_STATE% --initial-cluster-token %TOKEN%


set THIS_NAME=%NAME_2%
set THIS_IP=%HOST_2%
docker run ^
  -p 2379:2379 ^
  -p 2380:2380 ^
  --volume=%DATA_DIR%:/etcd-data ^
  --name etcd %REGISTRY%:%ETCD_VERSION% ^
  /usr/local/bin/etcd ^
  --data-dir=/etcd-data --name %THIS_NAME% ^
  --initial-advertise-peer-urls "http://%THIS_IP%:2380" --listen-peer-urls "http://0.0.0.0:2380" ^
  --advertise-client-urls "http://%THIS_IP%:2379" --listen-client-urls "http://0.0.0.0:2379" ^
  --initial-cluster %CLUSTER% ^
  --initial-cluster-state %CLUSTER_STATE% --initial-cluster-token %TOKEN%


set THIS_NAME=%NAME_3%
set THIS_IP=%HOST_3%
docker run ^
  -p 2379:2379 ^
  -p 2380:2380 ^
  --volume=%DATA_DIR%:/etcd-data ^
  --name etcd %REGISTRY%:%ETCD_VERSION% ^
  /usr/local/bin/etcd ^
  --data-dir=/etcd-data --name %THIS_NAME% ^
  --initial-advertise-peer-urls "http://%THIS_IP%:2380" --listen-peer-urls "http://0.0.0.0:2380" ^
  --advertise-client-urls "http://%THIS_IP%:2379" --listen-client-urls "http://0.0.0.0:2379" ^
  --initial-cluster %CLUSTER% ^
  --initial-cluster-state %CLUSTER_STATE% --initial-cluster-token %TOKEN%

When I run the .bat only of the nodes seem to be starting and I get these errors:

C:\Users\alexa\Downloads\etcd6\etcd-v3.5.0-windows-amd64>docker run   -p 2379:2379   -p 2380:2380   --name etcd gcr.io/etcd-development/etcd:latest   /usr/local/bin/etcd   --data-dir=/etcd-data --name etcd-node-0   --initial-advertise-peer-urls "http://10.20.30.1:2380" --listen-peer-urls "http://0.0.0.0:2380"   --advertise-client-urls "http://10.20.30.1:2379" --listen-client-urls "http://0.0.0.0:2379"   --initial-cluster etcd-node-0="http://10.20.30.1:2380",etcd-node-1="http://10.20.30.2:2380",etcd-node-2="http://10.20.30.3:2380"   --initial-cluster-state new --initial-cluster-token my-etcd-token
2021-07-28 10:21:39.548098 I | etcdmain: etcd Version: 3.3.12
2021-07-28 10:21:39.548183 I | etcdmain: Git SHA: d57e8b8
2021-07-28 10:21:39.548187 I | etcdmain: Go Version: go1.10.8
2021-07-28 10:21:39.548189 I | etcdmain: Go OS/Arch: linux/amd64
2021-07-28 10:21:39.548193 I | etcdmain: setting maximum number of CPUs to 4, total number of available CPUs is 4
2021-07-28 10:21:39.548443 I | embed: listening for peers on http://0.0.0.0:2380
2021-07-28 10:21:39.548482 I | embed: listening for client requests on 0.0.0.0:2379
2021-07-28 10:21:41.557265 I | etcdserver: name = etcd-node-0
2021-07-28 10:21:41.557394 I | etcdserver: data dir = /etcd-data
2021-07-28 10:21:41.557421 I | etcdserver: member dir = /etcd-data/member
2021-07-28 10:21:41.557434 I | etcdserver: heartbeat = 100ms
2021-07-28 10:21:41.557446 I | etcdserver: election = 1000ms
2021-07-28 10:21:41.557457 I | etcdserver: snapshot count = 100000
2021-07-28 10:21:41.557487 I | etcdserver: advertise client URLs = http://10.20.30.1:2379
2021-07-28 10:21:41.557502 I | etcdserver: initial advertise peer URLs = http://10.20.30.1:2380
2021-07-28 10:21:41.557592 I | etcdserver: initial cluster = etcd-node-0=http://10.20.30.1:2380,etcd-node-1=http://10.20.30.2:2380,etcd-node-2=http://10.20.30.3:2380
2021-07-28 10:21:41.583287 I | etcdserver: starting member 28be9c47fb4c898d in cluster d599a52d3806cc10
2021-07-28 10:21:41.583341 I | raft: 28be9c47fb4c898d became follower at term 0
2021-07-28 10:21:41.583354 I | raft: newRaft 28be9c47fb4c898d [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0]
2021-07-28 10:21:41.583361 I | raft: 28be9c47fb4c898d became follower at term 1
2021-07-28 10:21:41.593925 W | auth: simple token is not cryptographically signed
2021-07-28 10:21:41.601391 I | rafthttp: starting peer 824ad1694dacede...
2021-07-28 10:21:41.601556 I | rafthttp: started HTTP pipelining with peer 824ad1694dacede
2021-07-28 10:21:41.602888 I | rafthttp: started streaming with peer 824ad1694dacede (writer)
2021-07-28 10:21:41.603094 I | rafthttp: started streaming with peer 824ad1694dacede (writer)
2021-07-28 10:21:41.605978 I | rafthttp: started peer 824ad1694dacede
2021-07-28 10:21:41.606065 I | rafthttp: added peer 824ad1694dacede
2021-07-28 10:21:41.606092 I | rafthttp: starting peer 76ec72c18299cb2d...
2021-07-28 10:21:41.606103 I | rafthttp: started streaming with peer 824ad1694dacede (stream MsgApp v2 reader)
2021-07-28 10:21:41.606129 I | rafthttp: started HTTP pipelining with peer 76ec72c18299cb2d
2021-07-28 10:21:41.607376 I | rafthttp: started streaming with peer 824ad1694dacede (stream Message reader)
2021-07-28 10:21:41.607843 I | rafthttp: started streaming with peer 76ec72c18299cb2d (writer)
2021-07-28 10:21:41.609223 I | rafthttp: started streaming with peer 76ec72c18299cb2d (writer)
2021-07-28 10:21:41.609855 I | rafthttp: started peer 76ec72c18299cb2d
2021-07-28 10:21:41.609897 I | rafthttp: added peer 76ec72c18299cb2d
2021-07-28 10:21:41.609924 I | etcdserver: starting server... [version: 3.3.12, cluster version: to_be_decided]
2021-07-28 10:21:41.610559 I | rafthttp: started streaming with peer 76ec72c18299cb2d (stream MsgApp v2 reader)
2021-07-28 10:21:41.611784 I | rafthttp: started streaming with peer 76ec72c18299cb2d (stream Message reader)
2021-07-28 10:21:41.614570 I | etcdserver/membership: added member 824ad1694dacede [http://10.20.30.3:2380] to cluster d599a52d3806cc10
2021-07-28 10:21:41.615943 I | etcdserver/membership: added member 28be9c47fb4c898d [http://10.20.30.1:2380] to cluster d599a52d3806cc10
2021-07-28 10:21:41.616714 I | etcdserver/membership: added member 76ec72c18299cb2d [http://10.20.30.2:2380] to cluster d599a52d3806cc10
2021-07-28 10:21:42.584739 I | raft: 28be9c47fb4c898d is starting a new election at term 1
2021-07-28 10:21:42.584822 I | raft: 28be9c47fb4c898d became candidate at term 2
2021-07-28 10:21:42.584934 I | raft: 28be9c47fb4c898d received MsgVoteResp from 28be9c47fb4c898d at term 2
2021-07-28 10:21:42.584973 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 76ec72c18299cb2d at term 2
2021-07-28 10:21:42.584996 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 824ad1694dacede at term 2
2021-07-28 10:21:43.784669 I | raft: 28be9c47fb4c898d is starting a new election at term 2
2021-07-28 10:21:43.784871 I | raft: 28be9c47fb4c898d became candidate at term 3
2021-07-28 10:21:43.784917 I | raft: 28be9c47fb4c898d received MsgVoteResp from 28be9c47fb4c898d at term 3
2021-07-28 10:21:43.784942 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 824ad1694dacede at term 3
2021-07-28 10:21:43.784964 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 76ec72c18299cb2d at term 3
2021-07-28 10:21:45.684759 I | raft: 28be9c47fb4c898d is starting a new election at term 3
2021-07-28 10:21:45.684948 I | raft: 28be9c47fb4c898d became candidate at term 4
2021-07-28 10:21:45.684994 I | raft: 28be9c47fb4c898d received MsgVoteResp from 28be9c47fb4c898d at term 4
2021-07-28 10:21:45.685020 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 824ad1694dacede at term 4
2021-07-28 10:21:45.685042 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 76ec72c18299cb2d at term 4
2021-07-28 10:21:46.608076 W | rafthttp: health check for peer 824ad1694dacede could not connect: <nil> (prober "ROUND_TRIPPER_SNAPSHOT")
2021-07-28 10:21:46.608683 W | rafthttp: health check for peer 824ad1694dacede could not connect: <nil> (prober "ROUND_TRIPPER_RAFT_MESSAGE")
2021-07-28 10:21:46.612365 W | rafthttp: health check for peer 76ec72c18299cb2d could not connect: <nil> (prober "ROUND_TRIPPER_RAFT_MESSAGE")
2021-07-28 10:21:46.617880 W | rafthttp: health check for peer 76ec72c18299cb2d could not connect: <nil> (prober "ROUND_TRIPPER_SNAPSHOT")
2021-07-28 10:21:47.084248 I | raft: 28be9c47fb4c898d is starting a new election at term 4
2021-07-28 10:21:47.084359 I | raft: 28be9c47fb4c898d became candidate at term 5
2021-07-28 10:21:47.084387 I | raft: 28be9c47fb4c898d received MsgVoteResp from 28be9c47fb4c898d at term 5
2021-07-28 10:21:47.084403 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 824ad1694dacede at term 5
2021-07-28 10:21:47.084418 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 76ec72c18299cb2d at term 5
2021-07-28 10:21:48.584421 I | raft: 28be9c47fb4c898d is starting a new election at term 5
2021-07-28 10:21:48.584575 I | raft: 28be9c47fb4c898d became candidate at term 6
2021-07-28 10:21:48.584620 I | raft: 28be9c47fb4c898d received MsgVoteResp from 28be9c47fb4c898d at term 6
2021-07-28 10:21:48.584645 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 76ec72c18299cb2d at term 6
2021-07-28 10:21:48.584668 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 824ad1694dacede at term 6
2021-07-28 10:21:48.614273 E | etcdserver: publish error: etcdserver: request timed out
2021-07-28 10:21:50.184298 I | raft: 28be9c47fb4c898d is starting a new election at term 6
2021-07-28 10:21:50.184454 I | raft: 28be9c47fb4c898d became candidate at term 7
2021-07-28 10:21:50.184495 I | raft: 28be9c47fb4c898d received MsgVoteResp from 28be9c47fb4c898d at term 7
2021-07-28 10:21:50.184549 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 824ad1694dacede at term 7
2021-07-28 10:21:50.184573 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 76ec72c18299cb2d at term 7
2021-07-28 10:21:51.609415 W | rafthttp: health check for peer 824ad1694dacede could not connect: dial tcp 10.20.30.3:2380: i/o timeout (prober "ROUND_TRIPPER_SNAPSHOT")
2021-07-28 10:21:51.609644 W | rafthttp: health check for peer 824ad1694dacede could not connect: dial tcp 10.20.30.3:2380: i/o timeout (prober "ROUND_TRIPPER_RAFT_MESSAGE")
2021-07-28 10:21:51.613473 W | rafthttp: health check for peer 76ec72c18299cb2d could not connect: dial tcp 10.20.30.2:2380: i/o timeout (prober "ROUND_TRIPPER_RAFT_MESSAGE")
2021-07-28 10:21:51.620697 W | rafthttp: health check for peer 76ec72c18299cb2d could not connect: dial tcp 10.20.30.2:2380: i/o timeout (prober "ROUND_TRIPPER_SNAPSHOT")
2021-07-28 10:21:51.684250 I | raft: 28be9c47fb4c898d is starting a new election at term 7
2021-07-28 10:21:51.684322 I | raft: 28be9c47fb4c898d became candidate at term 8
2021-07-28 10:21:51.684341 I | raft: 28be9c47fb4c898d received MsgVoteResp from 28be9c47fb4c898d at term 8
2021-07-28 10:21:51.684353 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 76ec72c18299cb2d at term 8
2021-07-28 10:21:51.684363 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 824ad1694dacede at term 8
2021-07-28 10:21:52.684055 I | raft: 28be9c47fb4c898d is starting a new election at term 8
2021-07-28 10:21:52.684106 I | raft: 28be9c47fb4c898d became candidate at term 9
2021-07-28 10:21:52.684119 I | raft: 28be9c47fb4c898d received MsgVoteResp from 28be9c47fb4c898d at term 9
2021-07-28 10:21:52.684128 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 76ec72c18299cb2d at term 9
2021-07-28 10:21:52.684136 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 824ad1694dacede at term 9
2021-07-28 10:21:54.584287 I | raft: 28be9c47fb4c898d is starting a new election at term 9
2021-07-28 10:21:54.584364 I | raft: 28be9c47fb4c898d became candidate at term 10
2021-07-28 10:21:54.584390 I | raft: 28be9c47fb4c898d received MsgVoteResp from 28be9c47fb4c898d at term 10
2021-07-28 10:21:54.584414 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 76ec72c18299cb2d at term 10
2021-07-28 10:21:54.584437 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 824ad1694dacede at term 10
2021-07-28 10:21:55.615294 E | etcdserver: publish error: etcdserver: request timed out
2021-07-28 10:21:55.784578 I | raft: 28be9c47fb4c898d is starting a new election at term 10
2021-07-28 10:21:55.784736 I | raft: 28be9c47fb4c898d became candidate at term 11
2021-07-28 10:21:55.784780 I | raft: 28be9c47fb4c898d received MsgVoteResp from 28be9c47fb4c898d at term 11
2021-07-28 10:21:55.784804 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 824ad1694dacede at term 11
2021-07-28 10:21:55.784825 I | raft: 28be9c47fb4c898d [logterm: 1, index: 3] sent MsgVote request to 76ec72c18299cb2d at term 11
2021-07-28 10:21:56.610336 W | rafthttp: health check for peer 824ad1694dacede could not connect: dial tcp 10.20.30.3:2380: i/o timeout (prober "ROUND_TRIPPER_SNAPSHOT")
2021-07-28 10:21:56.610801 W | rafthttp: health check for peer 824ad1694dacede could not connect: dial tcp 10.20.30.3:2380: i/o timeout (prober "ROUND_TRIPPER_RAFT_MESSAGE")
2021-07-28 10:21:56.614030 W | rafthttp: health check for peer 76ec72c18299cb2d could not connect: dial tcp 10.20.30.2:2380: i/o timeout (prober "ROUND_TRIPPER_RAFT_MESSAGE")
2021-07-28 10:21:56.621988 W | rafthttp: health check for peer 76ec72c18299cb2d could not connect: dial tcp 10.20.30.2:2380: i/o timeout (prober "ROUND_TRIPPER_SNAPSHOT") 

When I run the command to check the member list the following appears:

C:\Users\alexa\Downloads\etcd6\etcd-v3.5.0-windows-amd64>docker exec etcd /bin/sh -c "export ETCDCTL_API=3 && /usr/local/bin/etcdctl put foo bar"
Error: context deadline exceeded

Running on windows 10 latest version of etcd. All the ports are open.
Appreciate all the help I can get.

@sakateka
Copy link
Contributor

sakateka commented Jul 28, 2021

Hi!

First of all, it seems that the bat script has launched only one node.
Secondly, each docker container must also have a unique name in --name etcd-№.
Try running each container in a separate console window.

You need to understand where you got the ip addresses 10.20.30.1 10.20.30.2 10.20.30.3, is there an ip address from the network 10.20.30.0/24 on the host system? If not, then you need to take free addresses from the network whose address is assigned on the docker interface. Or just try to use --net=host and replace all the ip addresses with literally localhost
This condition will ensure connectivity between the containers.

You need to understand the routing between docker containers.
You need to make sure that container №1 has an ip address of 10.20.30.1 in container №2 there is 10.20.30.2, etc.
After that, you need to make sure that container №1 can ping container №2 and №3...
In the end, the container with the etcdctl launch should work (you will have to provide it with an ip from the 10.20.30.0/24 network)

After all, please check the launch of etcdctl with --endpoints http://10.20.30.1:2379,http://10.20.30.2:2379,http://10.20.30.3:2379

@sakateka
Copy link
Contributor

I don't have windows nearby to check, but something like this should work

set CLUSTER=%NAME_1%="http://localhost:12380",%NAME_2%="http://localhost:22380",%NAME_3%="http://localhost:32380"

console window №1

docker run --net=host ^
  --volume=%DATA_DIR%:/etcd-data ^
  --name etcd-1 %REGISTRY%:%ETCD_VERSION% ^
  /usr/local/bin/etcd ^
  --data-dir=/etcd-data --name %THIS_NAME% ^
  --initial-advertise-peer-urls "http://localhost:12380" --listen-peer-urls "http://localhost:12380" ^
  --advertise-client-urls "http://localhost:12379" --listen-client-urls "http://localhost:12379" ^
  --initial-cluster %CLUSTER% ^
  --initial-cluster-state %CLUSTER_STATE% --initial-cluster-token %TOKEN%

console window №2

docker run --net=host ^
  --volume=%DATA_DIR%:/etcd-data ^
  --name etcd-2 %REGISTRY%:%ETCD_VERSION% ^
  /usr/local/bin/etcd ^
  --data-dir=/etcd-data --name %THIS_NAME% ^
  --initial-advertise-peer-urls "http://localhost:22380" --listen-peer-urls "http://localhost:22380" ^
  --advertise-client-urls "http://localhost:22379" --listen-client-urls "http://localhost:22379" ^
  --initial-cluster %CLUSTER% ^
  --initial-cluster-state %CLUSTER_STATE% --initial-cluster-token %TOKEN%

console window №3

docker run --net=host ^
  --volume=%DATA_DIR%:/etcd-data ^
  --name etcd-3 %REGISTRY%:%ETCD_VERSION% ^
  /usr/local/bin/etcd ^
  --data-dir=/etcd-data --name %THIS_NAME% ^
  --initial-advertise-peer-urls "http://localhost:32380" --listen-peer-urls "http://localhost:32380" ^
  --advertise-client-urls "http://localhost:32379" --listen-client-urls "http://localhost:32379" ^
  --initial-cluster %CLUSTER% ^
  --initial-cluster-state %CLUSTER_STATE% --initial-cluster-token %TOKEN%

console window for etcdctl (note that we are connecting to the container with etcd №1)

docker exec etcd-1 ^
  ETCDCTL_API=3 /usr/local/bin/etcdctl --endpoints localhost:12379,localhost:22379,localhost:32379 endpoint health

Adopted for windows from http://play.etcd.io/install#top

@brovatten
Copy link
Author

Thank you for your comments. So I tried by copying adding your examples to separate batch files resulting in this for the first node

set REGISTRY=quay.io/coreos/etcd

set REGISTRY=gcr.io/etcd-development/etcd

# For each machine
set ETCD_VERSION=latest
set TOKEN=my-etcd-token
set CLUSTER_STATE=new
set NAME_1=etcd-node-0
set NAME_2=etcd-node-1
set NAME_3=etcd-node-2
set HOST_1=10.20.30.1
set HOST_2=10.20.30.2
set HOST_3=10.20.30.3
set CLUSTER=%NAME_1%="http://%HOST_1%:2380",%NAME_2%="http://%HOST_2%:2380",%NAME_3%="http://%HOST_3%:2380"
set DATA_DIR ="/var/lib/etcd"
set CLUSTER=%NAME_1%="http://localhost:12380",%NAME_2%="http://localhost:22380",%NAME_3%="http://localhost:32380"
set THIS_NAME=%NAME_1%
docker run --net=host ^
  --volume=%DATA_DIR%:/etcd-data ^
  --name etcd-1 %REGISTRY%:%ETCD_VERSION% ^
  /usr/local/bin/etcd ^
  --data-dir=/etcd-data --name %THIS_NAME% ^
  --initial-advertise-peer-urls "http://localhost:12380" --listen-peer-urls "http://localhost:12380" ^
  --advertise-client-urls "http://localhost:12379" --listen-client-urls "http://localhost:12379" ^
  --initial-cluster %CLUSTER% ^
  --initial-cluster-state %CLUSTER_STATE% --initial-cluster-token %TOKEN%

However, this resulted in the following error. Even when I tried to change my path this occurred. It might be because the build.bat file didn't work so I am working in a directory instead (not sure if that makes sense)

docker: Error response from daemon: OCI runtime create failed: invalid mount {Destination::/etcd-data Type:bind Source:/var/lib/docker/volumes/188588ab0df2bd2a0d065b6190878bf8a8e3b743306c81e4c9d550a8272b8473/_data Options:[rbind]}: mount destination :/etcd-data not absolute: unknown.

I found then others had said it worked when they removed the volume, so I did and I think this produced a correct log? (Thought they would keep electing?)

C:\Users\alexa\Downloads\etcd6\etcd-v3.5.0-windows-amd64>docker run --net=host   --name etcd-1 gcr.io/etcd-development/etcd:latest   /usr/local/bin/etcd   --data-dir=/etcd-data --name etcd-node-0   --initial-advertise-peer-urls "http://localhost:12380" --listen-peer-urls "http://localhost:12380"   --advertise-client-urls "http://localhost:12379" --listen-client-urls "http://localhost:12379"   --initial-cluster etcd-node-0="http://localhost:12380",etcd-node-1="http://localhost:22380",etcd-node-2="http://localhost:32380"   --initial-cluster-state new --initial-cluster-token my-etcd-token
2021-07-29 10:46:22.872994 I | etcdmain: etcd Version: 3.3.12
2021-07-29 10:46:22.873075 I | etcdmain: Git SHA: d57e8b8
2021-07-29 10:46:22.873080 I | etcdmain: Go Version: go1.10.8
2021-07-29 10:46:22.873089 I | etcdmain: Go OS/Arch: linux/amd64
2021-07-29 10:46:22.873094 I | etcdmain: setting maximum number of CPUs to 4, total number of available CPUs is 4
2021-07-29 10:46:22.873563 I | embed: listening for peers on http://localhost:12380
2021-07-29 10:46:22.873688 I | embed: listening for client requests on localhost:12379
2021-07-29 10:46:22.951687 I | etcdserver: name = etcd-node-0
2021-07-29 10:46:22.951745 I | etcdserver: data dir = /etcd-data
2021-07-29 10:46:22.951756 I | etcdserver: member dir = /etcd-data/member
2021-07-29 10:46:22.951761 I | etcdserver: heartbeat = 100ms
2021-07-29 10:46:22.951766 I | etcdserver: election = 1000ms
2021-07-29 10:46:22.951770 I | etcdserver: snapshot count = 100000
2021-07-29 10:46:22.951781 I | etcdserver: advertise client URLs = http://localhost:12379
2021-07-29 10:46:22.951787 I | etcdserver: initial advertise peer URLs = http://localhost:12380
2021-07-29 10:46:22.951805 I | etcdserver: initial cluster = etcd-node-0=http://localhost:12380,etcd-node-1=http://localhost:22380,etcd-node-2=http://localhost:32380
2021-07-29 10:46:22.997537 I | etcdserver: starting member 7ef6eed682a61a58 in cluster 8c37cd19e3dfabf7
2021-07-29 10:46:22.997661 I | raft: 7ef6eed682a61a58 became follower at term 0
2021-07-29 10:46:22.997677 I | raft: newRaft 7ef6eed682a61a58 [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0]
2021-07-29 10:46:22.997682 I | raft: 7ef6eed682a61a58 became follower at term 1
2021-07-29 10:46:23.014436 W | auth: simple token is not cryptographically signed
2021-07-29 10:46:23.024813 I | rafthttp: starting peer 1640829d9eea5cfb...
2021-07-29 10:46:23.024957 I | rafthttp: started HTTP pipelining with peer 1640829d9eea5cfb
2021-07-29 10:46:23.026788 I | rafthttp: started streaming with peer 1640829d9eea5cfb (writer)
2021-07-29 10:46:23.027073 I | rafthttp: started streaming with peer 1640829d9eea5cfb (writer)
2021-07-29 10:46:23.028955 I | rafthttp: started peer 1640829d9eea5cfb
2021-07-29 10:46:23.029015 I | rafthttp: added peer 1640829d9eea5cfb
2021-07-29 10:46:23.029035 I | rafthttp: starting peer f5cc69eb6f6f9b17...
2021-07-29 10:46:23.029320 I | rafthttp: started HTTP pipelining with peer f5cc69eb6f6f9b17
2021-07-29 10:46:23.029537 I | rafthttp: started streaming with peer 1640829d9eea5cfb (stream Message reader)
2021-07-29 10:46:23.029754 I | rafthttp: started streaming with peer 1640829d9eea5cfb (stream MsgApp v2 reader)
2021-07-29 10:46:23.031151 I | rafthttp: peer 1640829d9eea5cfb became active
2021-07-29 10:46:23.031194 I | rafthttp: established a TCP streaming connection with peer 1640829d9eea5cfb (stream MsgApp v2 reader)
2021-07-29 10:46:23.031266 I | rafthttp: started streaming with peer f5cc69eb6f6f9b17 (writer)
2021-07-29 10:46:23.034483 I | rafthttp: started peer f5cc69eb6f6f9b17
2021-07-29 10:46:23.034572 I | rafthttp: added peer f5cc69eb6f6f9b17
2021-07-29 10:46:23.034592 I | etcdserver: starting server... [version: 3.3.12, cluster version: to_be_decided]
2021-07-29 10:46:23.034828 I | rafthttp: started streaming with peer f5cc69eb6f6f9b17 (writer)
2021-07-29 10:46:23.034919 I | rafthttp: started streaming with peer f5cc69eb6f6f9b17 (stream MsgApp v2 reader)
2021-07-29 10:46:23.037208 I | rafthttp: started streaming with peer f5cc69eb6f6f9b17 (stream Message reader)
2021-07-29 10:46:23.043119 I | rafthttp: established a TCP streaming connection with peer 1640829d9eea5cfb (stream Message reader)
2021-07-29 10:46:23.044434 I | etcdserver/membership: added member 1640829d9eea5cfb [http://localhost:22380] to cluster 8c37cd19e3dfabf7
2021-07-29 10:46:23.044579 I | etcdserver/membership: added member 7ef6eed682a61a58 [http://localhost:12380] to cluster 8c37cd19e3dfabf7
2021-07-29 10:46:23.044855 I | etcdserver/membership: added member f5cc69eb6f6f9b17 [http://localhost:32380] to cluster 8c37cd19e3dfabf7
2021-07-29 10:46:23.045696 I | rafthttp: established a TCP streaming connection with peer 1640829d9eea5cfb (stream MsgApp v2 writer)
2021-07-29 10:46:23.046282 I | rafthttp: established a TCP streaming connection with peer 1640829d9eea5cfb (stream Message writer)
2021-07-29 10:46:23.129382 I | rafthttp: peer f5cc69eb6f6f9b17 became active
2021-07-29 10:46:23.129554 I | rafthttp: established a TCP streaming connection with peer f5cc69eb6f6f9b17 (stream MsgApp v2 writer)
2021-07-29 10:46:23.130435 I | rafthttp: established a TCP streaming connection with peer f5cc69eb6f6f9b17 (stream Message writer)
2021-07-29 10:46:23.131077 I | rafthttp: established a TCP streaming connection with peer f5cc69eb6f6f9b17 (stream MsgApp v2 reader)
2021-07-29 10:46:23.131538 I | rafthttp: established a TCP streaming connection with peer f5cc69eb6f6f9b17 (stream Message reader)
2021-07-29 10:46:23.139099 I | etcdserver: 7ef6eed682a61a58 initialzed peer connection; fast-forwarding 8 ticks (election ticks 10) with 2 active peer(s)
2021-07-29 10:46:23.142709 I | raft: 7ef6eed682a61a58 [term: 1] received a MsgVote message with higher term from 1640829d9eea5cfb [term: 2]
2021-07-29 10:46:23.142733 I | raft: 7ef6eed682a61a58 became follower at term 2
2021-07-29 10:46:23.142744 I | raft: 7ef6eed682a61a58 [logterm: 1, index: 3, vote: 0] cast MsgVote for 1640829d9eea5cfb [logterm: 1, index: 3] at term 2
2021-07-29 10:46:23.149917 I | raft: raft.node: 7ef6eed682a61a58 elected leader 1640829d9eea5cfb at term 2
2021-07-29 10:46:23.194767 I | etcdserver: published {Name:etcd-node-0 ClientURLs:[http://localhost:12379]} to cluster 8c37cd19e3dfabf7
2021-07-29 10:46:23.195144 N | etcdserver/membership: set the initial cluster version to 3.3
2021-07-29 10:46:23.195893 I | etcdserver/api: enabled capabilities for version 3.3
2021-07-29 10:46:23.196063 I | embed: ready to serve client requests
2021-07-29 10:46:23.197674 N | embed: serving insecure client requests on 127.0.0.1:12379, this is strongly discouraged!

Etcdctl however won't respond when I try the command you mentioned and the one given on the website.

C:\Users\alexa\Downloads\etcd6\etcd-v3.5.0-windows-amd64>docker exec etcd-1 ^
More?   ETCDCTL_API=3 /usr/local/bin/etcdctl --endpoints localhost:12379,localhost:22379,localhost:32379 endpoint health
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "ETCDCTL_API=3": executable file not found in $PATH: unknown

C:\Users\alexa\Downloads\etcd6\etcd-v3.5.0-windows-amd64>etcdctl --endpoints=http://localhost:2379 member list
{"level":"warn","ts":"2021-07-29T13:15:52.373+0200","logger":"etcd-client","caller":"v3/retry_interceptor.go:62","msg":"retrying of unary invoker failed","target":"etcd-endpoints://0xc00020bdc0/#initially=[http://localhost:2379]","attempt":0,"error":"rpc error: code = DeadlineExceeded desc = latest balancer error: last connection error: connection error: desc = \"transport: Error while dialing dial tcp [::1]:2379: connectex: No connection could be made because the target machine actively refused it.\""}
Error: context deadline exceeded

Do you have an idea of what is wrong?

@sakateka
Copy link
Contributor

sakateka commented Jul 29, 2021

Do you have an idea of what is wrong?

Of course, there is very little left that is not true)))
You need to run three nodes at the same time, since they are specified in the --initial-cluster
And set DATA_DIR ="/var/lib/etcd" is not valid path for windows, try to change to set DATA_DIR ="c:\\path\you\want\to\store\data" or just delete volume as you did.
If volume is disabled, all data will remain inside the containers
To run etcdctl, try doing this (added bash -c)

docker exec etcd-1 bash -c "ETCDCTL_API=3 /usr/local/bin/etcdctl --endpoints localhost:12379,localhost:22379,localhost:32379 endpoint health"

Or correct your second etcdctl command, you specified the wrong port, for node 1, the port should be 12379

@brovatten
Copy link
Author

My apologies for that. However, when I use the correct port the error persists

C:\Users\alexa\Downloads\etcd6\etcd-v3.5.0-windows-amd64>etcdctl --endpoints=http://localhost:12379 member list
{"level":"warn","ts":"2021-07-29T14:19:53.738+0200","logger":"etcd-client","caller":"v3/retry_interceptor.go:62","msg":"retrying of unary invoker failed","target":"etcd-endpoints://0xc00034a540/#initially=[http://localhost:12379]","attempt":0,"error":"rpc error: code = DeadlineExceeded desc = latest balancer error: last connection error: connection error: desc = \"transport: Error while dialing dial tcp [::1]:12379: connectex: No connection could be made because the target machine actively refused it.\""}
Error: context deadline exceeded

and when using the command you provided

C:\Users\alexa\Downloads\etcd6\etcd-v3.5.0-windows-amd64>docker exec etcd-1 bash -c "ETCDCTL_API=3 /usr/local/bin/etcdctl --endpoints localhost:12379,localhost:22379,localhost:32379 endpoint health"
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "bash": executable file not found in $PATH: unknown

and when specifying the path of my etcdctl.exe

C:\Users\alexa\Downloads\etcd6\etcd-v3.5.0-windows-amd64>docker exec etcd-1 bash -c "ETCDCTL_API=3 C:\Users\alexa\Downloads\etcd6\etcd-v3.5.0-windows-amd64\etcdctl --endpoints localhost:12379,localhost:22379,localhost:32379 endpoint health"
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "bash": executable file not found in $PATH: unknown

@sakateka
Copy link
Contributor

Hmm, there was no bash in the image :-(
That's how it works
console 1
docker run --net=host --name etcd-1 gcr.io/etcd-development/etcd:latest /usr/local/bin/etcd --data-dir=/etcd-data --name etcd-1 --initial-advertise-peer-urls "http://localhost:12380" --listen-peer-urls "http://localhost:12380" --advertise-client-urls "http://localhost:12379" --listen-client-urls "http://localhost:12379" --initial-cluster etcd-1=http://localhost:12380,etcd-2=http://localhost:22380,etcd-3=http://localhost:32380 --initial-cluster-state new --initial-cluster-token tkn

console 2
docker run --net=host --name etcd-2 gcr.io/etcd-development/etcd:latest /usr/local/bin/etcd --data-dir=/etcd-data --name etcd-2 --initial-advertise-peer-urls "http://localhost:22380" --listen-peer-urls "http://localhost:22380" --advertise-client-urls "http://localhost:22379" --listen-client-urls "http://localhost:22379" --initial-cluster etcd-1=http://localhost:12380,etcd-2=http://localhost:22380,etcd-3=http://localhost:32380 --initial-cluster-state new --initial-cluster-token tkn

console 3
docker run --net=host --name etcd-3 gcr.io/etcd-development/etcd:latest /usr/local/bin/etcd --data-dir=/etcd-data --name etcd-3 --initial-advertise-peer-urls "http://localhost:32380" --listen-peer-urls "http://localhost:32380" --advertise-client-urls "http://localhost:32379" --listen-client-urls "http://localhost:32379" --initial-cluster etcd-1=http://localhost:12380,etcd-2=http://localhost:22380,etcd-3=http://localhost:32380 --initial-cluster-state new --initial-cluster-token tkn

console 4

docker exec etcd-1 /bin/sh -c "ETCDCTL_API=3 /usr/local/bin/etcdctl --endpoints localhost:12379,localhost:22379,localhost:32379 endpoint health"
localhost:12379 is healthy: successfully committed proposal: took = 1.281415ms
localhost:32379 is healthy: successfully committed proposal: took = 1.357287ms
localhost:22379 is healthy: successfully committed proposal: took = 1.413632ms

@brovatten
Copy link
Author

Thank you so much, it seems to be working!

Hope I can bother you with two more questions.

  1. Firstly, I wonder how I now can put and get from the containers as my kvClient (using jetcd) does not seem to be working, which it did when I simply launched 1 node outside of docker.

  2. Second, is there a way to compare key values in the key-value store and if for instance value of key foo1 is equal to value of key foo2, then put a new (key,value), and make this in one request. I wonder as I wish to minimize space in raft, and to ensure integrity I can't make a get request before and then store, as things could have changed between the time I receive the key-value pair.

Feel free to refer to somewhere to read. My problem googling these problems has been the lack of tutorials and forums.

@sakateka
Copy link
Contributor

  1. It will not be possible to overcome network problems in a bundle of docker + windows without a week of immersion in all the subtleties of configuring the windows network : - (
    Therefore, the easiest way for you is to run one ubuntu container, and in it, according to the instructions for bare metal http://play.etcd.io/install#top, run 3 etcd processes.
    A contener with ubuntu will need to expose the three ports used to launch etcd.
  2. This is beyond the scope of the current discussion, please make a separate issue.

@brovatten
Copy link
Author

Alright thank you very much! You have saved me weeks of work.
I will :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants