I have question about docker redis-sentinel:5.0.10 startup issue.
I am running docker on CentOS7 Linux.
Before 5.0.10 version I used 4.0.9 and image was taken from our own repository, now I switched to bitnami repo.
The main problem is that I try to use redis-sentinel:5.0.10 (or redis-sentinel:5.0.7) and it falls into restart loop and cannot start properly.
I run containers like that:
[root#XXX opt]# docker run -d -p 26380:26379 -v /opt/app/redis:/data --name redis-sentinel -e REDIS_MASTER_HOST=XXX.XXX.XXX -e REDIS_MASTER_SET=XXX-XXX -e REDIS_SENTINEL_DOWN_AFTER_MILLISECONDS=30000 -e REDIS_SENTINEL_QUORUM=2 -e REDIS_SENTINEL_FAILOVER_TIMEOUT=180000 --net=host --restart=always bitnami/redis-sentinel:5.0.10
[root#XXX opt]# docker run -d --net=host -v /opt/app/redis:/data -v /opt/app/redis.conf:/usr/local/etc/redis/redis.conf --name redis-client --restart=always redis:5.0.10-alpine redis-server --slaveof XXX.XXX.XXX 6379
In log there are messages like:
redis-sentinel 10:16:50.45 Welcome to the Bitnami redis-sentinel container
redis-sentinel 10:16:50.45 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-redis-sentinel
redis-sentinel 10:16:50.45 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-redis-sentinel/issues
redis-sentinel 10:16:50.46
redis-sentinel 10:16:50.46 INFO ==> ** Starting Redis sentinel setup **
redis-sentinel 10:16:50.47 ERROR ==> The configuration file /opt/bitnami/redis-sentinel/etc/sentinel.conf is not writable
Why it is not writable?
[root#dam31 ~]# docker run --rm -it bitnami/redis-sentinel:5.0.10 sh
redis-sentinel 14:03:36.16
redis-sentinel 14:03:36.16 Welcome to the Bitnami redis-sentinel container
redis-sentinel 14:03:36.17 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-redis-sentinel
redis-sentinel 14:03:36.17 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-redis-sentinel/issues
redis-sentinel 14:03:36.17
$ cd /opt/bitnami/redis-sentinel/etc/
$ ls -l
total 12
-rw-rw-r-- 1 root root 9797 Dec 8 13:25 sentinel.conf
docker ps command says:
[root#XXX app]# docker ps --no-trunc
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
45988acb45407dfc7a19f4a2a08da7c8f7a99381a97bc17a3ae985d377605462 redis:5.0.10-alpine "docker-entrypoint.sh redis-server --slaveof XXX.XXX.XXX 6379" 4 minutes ago Up 3 minutes redis-client
94b9b8e712e2219bc3f9a18aba349985968e3410c5336905282fb43b38e89e8e bitnami/redis-sentinel:5.0.10 "/opt/bitnami/scripts/redis-sentinel/entrypoint.sh /opt/bitnami/scripts/redis-sentinel/run.sh" 4 minutes ago Restarting (1) 19 seconds ago redis-sentinel
On other machines I have upgraded redis to 5.0.7 version successfully and it runs properly, nothing was done otherwise:
[root#XXX app]# docker ps --no-trunc
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
07e535350c02a67478dd07708a06798981fe7e99ae448567837dacdee198ec1e redis:5.0.7-alpine "docker-entrypoint.sh redis-server /usr/local/etc/redis/redis.conf --slaveof XXX.XXX.XXX 6379" 8 weeks ago Up 8 weeks redis-client
fea1bff3b2c1fbc9c7cea2becad64b7e2727dfc1f73f1d541e08b9b75143b3a9 bitnami/redis-sentinel:5.0.7 "/entrypoint.sh /run.sh" 8 weeks ago Up 8 weeks redis-sentinel
If I run on the same machine (where I tried to run redis:5.0.10) redis:5.0.7 the same error occured:
[root#XXX ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
15cdd46fa325 redis:5.0.7-alpine "docker-entrypoint.s…" 15 minutes ago Up 15 minutes redis-client
b0b02a36b68c bitnami/redis-sentinel:5.0.7 "/entrypoint.sh /run…" 16 minutes ago Restarting (1) 50 seconds ago redis-sentinel
redis-sentinel 14:16:23.86 Welcome to the Bitnami redis-sentinel container
redis-sentinel 14:16:23.87 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-redis-sentinel
redis-sentinel 14:16:23.87 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-redis-sentinel/issues
redis-sentinel 14:16:23.87 Send us your feedback at containers#bitnami.com
redis-sentinel 14:16:23.87
redis-sentinel 14:16:23.87 INFO ==> ** Starting Redis sentinel setup **
redis-sentinel 14:16:23.88 ERROR ==> The configuration file /opt/bitnami/redis-sentinel/etc/sentinel.conf is not writable
What I am doing wrong? Any thoughts? (NB! SELinux is disabled)
Related
I am trying to connect to redis containers together to share some data, but I'm not having much luck. First I create a new docker container:
➜ docker-react git:(master) ✗ docker run -d --name red1 -v ~/vol:/data redis
7cec6f4fce354c3c603ef36813d9b8f41b446278b76bc8f05a901980bb864241
➜ docker-react git:(master) ✗ docker run -d --name red2 -v ~/vol:/data redis
566d4728cd8d2548a1ba4631bb118699157e03aae32a4566370fafdfae93463d
➜ docker-react git:(master) ✗ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
566d4728cd8d redis "docker-entrypoint.s…" 9 seconds ago Up 8 seconds 6379/tcp red2
7cec6f4fce35 redis "docker-entrypoint.s…" 20 seconds ago Up 19 seconds 6379/tcp red1
But when I go into 1 container and set some data, for example:
➜ docker-react git:(master) ✗ docker exec -it 566d4728cd8d redis-cli
127.0.0.1:6379> SET name Jim
OK
127.0.0.1:6379> SET age 20
OK
127.0.0.1:6379> get name
"Jim"
127.0.0.1:6379>
and then I go into the 2nd container, it is oblivious to the data:
➜ docker-react git:(master) ✗ docker exec -it 7cec6f4fce35 redis-cli
127.0.0.1:6379> get name
(nil)
127.0.0.1:6379>
Why? How can I connect these 2 containers to share the same data?
For me it looks like you are just launching two container of redis using the same volume. Have you setup those instances to store the data at the volumes location?
I have tests which run in a docker container. For this, I use docker-dind service, my .gitlab-ci:
image: "docker:17"
variables:
DOCKER_DRIVER: overlay2
services:
- docker:dind
- name: docker.elastic.co/elasticsearch/elasticsearch:5.5.2
alias: elasticsearch
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
stages:
- test
before_script:
- apk --update add py2-pip python3 bash zip ansible openssh git docker-py curl
- pip3 install docker-compose
- docker info
- docker-compose --version
# Login to registry.gitlab.com
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
test:
script:
- curl "http://elasticsearch:9200" # this works
- docker-compose docker-compose.test.yml build --pull
- docker-compose docker-compose.test.yml run app
stage: test
My tests use ES for this I added ES service but I can't connect to ES cluster from my container where I run tests.
On my machine with runner when CI works I have:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f5d9a64bbe8e 1ee5a99eba5f "gitlab-runner-build" 1 second ago Up Less than a second runner-b7dcaf73-project-2199705-concurrent-1-predefined-0
c85c49d35946 ca27036dd5e7 "bin/elasticsearch -…" 16 seconds ago Up 15 seconds 9200/tcp, 9300/tcp runner-b7dcaf73-project-2199705-concurrent-1-docker.elastic.co__elasticsearch__elasticsearch-1
57472d0300ad 85e924caedbd "dockerd-entrypoint.…" 17 seconds ago Up 16 seconds 2375/tcp runner-b7dcaf73-project-2199705-concurrent-1-docker-0
598c019aa28c - a container with a runner, I can enter to this container run curl "http://elasticsearch:9200" and it works
57472d0300ad - dind container, right? I can enter to this container but curl "http://elasticsearch:9200" doesn't work, docker ps shows:
/ # docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
252f0588a41d backend_app "make _inside_docker…" 6 seconds ago Up 5 seconds 8080/tcp backend_app_run_116d12907320
cd0ebb2f1d2d postgres:9.6 "docker-entrypoint.s…" 7 seconds ago Up 6 seconds 5432/tcp backend_postgresql_1
How I can connect from my container with tests (252f0588a41d) to container with ES?
Thanks.
In Docker Swarm mode, how can I restart a single global service? Is it even possible? I know you can scale replicated services to zero then back to 1+, but there doesn't appear to be any documentation on how to have the same effect with global services.
I am updating my SSL certificate so would like to just restart our reverse proxy instead of restarting our entire app (via restarting the docker service).
The docs just mention you cannot scale global services:
The scale command enables you to scale one or more replicated services either up or down to the desired number of replicas. This command cannot be applied on services which are global mode.
You can force a rolling update of a service, either globally scheduled or replicated using docker service update --force ${service_name}. Here's an example compose file:
version: '3'
services:
busybox-global:
image: busybox
command: tail -f /dev/null
deploy:
mode: global
busybox-replicated:
image: busybox
command: tail -f /dev/null
deploy:
replicas: 2
Verify it has started:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
917aefdc910b busybox:latest "tail -f /dev/null" 50 seconds ago Up 31 seconds sched_busybox-global.q44zx0s2lvu1fdduk800e5ini.hzn6jnzh7x539timamphzzw8a
7187fbbde0da busybox:latest "tail -f /dev/null" About a minute ago Up 31 seconds sched_busybox-replicated.1.i4nm7lpr1spmf0aorh1dtcqrc
f04a0062b088 busybox:latest "tail -f /dev/null" About a minute ago Up 31 seconds sched_busybox-replicated.2.oc6zn0ziqg9wyzofokek8eb24
$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
gto0d5a6betb sched_busybox-global global 1/1 busybox:latest
yfq5mne0qhtj sched_busybox-replicated replicated 2/2 busybox:latest
$ docker service ps sched_busybox-global
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
hzn6jnzh7x53 sched_busybox-global.q44zx0s2lvu1fdduk800e5ini busybox:latest bmitch-asusr556l Running Running 49 seconds ago
Force the rolling update:
$ docker service update --force sched_busybox-global
sched_busybox-global
overall progress: 1 out of 1 tasks
q44zx0s2lvu1: running [==================================================>]
verify: Service converged
$ docker service ps sched_busybox-global
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
zcfocrfjvvux sched_busybox-global.q44zx0s2lvu1fdduk800e5ini busybox:latest bmitch-asusr556l Running Running 7 seconds ago
hzn6jnzh7x53 \_ sched_busybox-global.q44zx0s2lvu1fdduk800e5ini busybox:latest bmitch-asusr556l Shutdown Shutdown 10 seconds ago
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3c5fe0f79e3d busybox:latest "tail -f /dev/null" About a minute ago Up About a minute sched_busybox-global.q44zx0s2lvu1fdduk800e5ini.zcfocrfjvvuxz6tkge0pn0bq2
917aefdc910b busybox:latest "tail -f /dev/null" 3 minutes ago Exited (137) About a minute ago sched_busybox-global.q44zx0s2lvu1fdduk800e5ini.hzn6jnzh7x539timamphzzw8a
7187fbbde0da busybox:latest "tail -f /dev/null" 3 minutes ago Up 2 minutes sched_busybox-replicated.1.i4nm7lpr1spmf0aorh1dtcqrc
f04a0062b088 busybox:latest "tail -f /dev/null" 3 minutes ago Up 2 minutes sched_busybox-replicated.2.oc6zn0ziqg9wyzofokek8eb24
The same would have worked if I forced an update to the replicated service.
I have the following setup:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
eab42051ca26 web-www:20180804 "node run.js" 8 minutes ago Up 8 minutes 3000/tcp web-www
63ec48e93a77 jwilder/nginx-proxy:latest "/app/docker-entrypo…" 9 hours ago Up 9 hours 0.0.0.0:80->80/tcp nginx-proxy-server
463ffd55260b fiorix/freegeoip "/go/bin/freegeoip" 9 hours ago Up 9 hours 8080/tcp freegeoip
bdc702c370ec euvat "/usr/local/bin/euva…" 9 hours ago Up 9 hours 3000/tcp euvat
40c07de732fa redis:4.0.10 "docker-entrypoint.s…" 9 hours ago Up 9 hours 6379/tcp redis-www
76831834f59d mongo:4.0 "docker-entrypoint.s…" 9 hours ago Up 9 hours 27017/tcp mongo-www
where my web-www node.js app connects to redis and mongo via the
NETWORK ID NAME DRIVER SCOPE
74d8f38aca38 bridge bridge local
1c894a7fa176 host host local
ca02c5ccac55 network-www bridge local
7226d9cc5360 none null local
my run.sh file is like:
OLDAPP="$(docker ps --all --quiet --filter=name="$APP")"
if [ -n "$OLDAPP" ]; then
docker stop $OLDAPP && docker rm $OLDAPP
fi
docker run --name web-www \
--network network-www \
--link euvat:euvat \
--link freegeoip:freegeoip \
--env VIRTUAL_HOST=araweelo.local \
--env-file /env/web-www.env \
web-www:20180804.182446
so, now i am starting a new development stack dev-www for example, so i will create the network-dev, launch redis-dev and mongo-dev but want to share the euvat and freegeoip containers with the web-www container.
is this the correct way to do this or is there an alternative method?
any advice is much appreciated.
Docker links are deprecated and maybe removed soon.
It's better to create the networks, containers ahead of time and join the container to the network
docker network create network-www
docker run --name web-www \
--env VIRTUAL_HOST=araweelo.local \
--env-file /env/web-www.env \
web-www:20180804.182446
docker network connect network-www web-www
docker network connect network-www euvat
docker network connect network-www freegeoip
This above commands will create a network-www user-defined bridge network and connect euvat, web-www and freegeoip containers to that network.
Replace/add containers as required. Might be a better idea to write a compose file which brings up the containers in a single command
The fabcar example of the hyperledger tutorial crashes for me at the step of attempting to run query.js.
I have removed all hyperledger related docker images (with docker rmi), so all required content was downloaded automatically when running startFabric.sh. The output on startup looks slightly "clouded" but not very suspicious (I skipped the lengthy output about the images being downloaded):
# wait for Hyperledger Fabric to start
# incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number>
export FABRIC_START_TIMEOUT=10
#echo ${FABRIC_START_TIMEOUT}
sleep ${FABRIC_START_TIMEOUT}
# Create the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.example.com/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx
flag provided but not defined: -e
See 'docker exec --help'.
The next step as asked is
npm install
It also delivers mostly ok output,just one warning:
npm WARN fabcar#1.0.0 No repository field.
I have verified images are running (also shows that the user is authorized to use the docker, while the user is otherwise not root):
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9acf0dd8a2e2 hyperledger/fabric-peer:x86_64-1.0.0 "peer node start" 20 seconds ago Up 19 seconds 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
da42dca3cbda hyperledger/fabric-orderer:x86_64-1.0.0 "orderer" 20 seconds ago Up 19 seconds 0.0.0.0:7050->7050/tcp orderer.example.com
0265c3cd86f2 hyperledger/fabric-ca:x86_64-1.0.0 "sh -c 'fabric-ca-ser" 20 seconds ago Up 20 seconds 0.0.0.0:7054->7054/tcp ca.example.com
4f71895a78c0 hyperledger/fabric-couchdb:x86_64-1.0.0 "tini -- /docker-entr" 20 seconds ago Up 19 seconds 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb
When I finally try to run
node query.js
I observe the following errors:
Create a client and set the wallet location
Set wallet path, and associate user PeerAdmin with application
Check user is enrolled, and set a query URL in the network
Make query
Assigning transaction_id: eb03c5e69259b880433861daf57a5ac2d33e41d93cebe80a7a478a1aa2cba711
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: Endpoint read failed
at /home/hla/fabric-samples/fabcar/node_modules/grpc/src/node/src/client.js:434:17
returned from query
Query result count = 1
error from query = { Error: Endpoint read failed
at /home/hla/fabric-samples/fabcar/node_modules/grpc/src/node/src/client.js:434:17 code: 14, metadata: Metadata { _internal_repr: {} } }
Response is Error: Endpoint read failed
My OS:
uname -a
Linux uhost 4.4.0-92-generic #115-Ubuntu SMP Thu Aug 10 09:04:33 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
I have checked this but my node.js version is correct:
node --version
v6.11.2
npm -- version
{ fabcar: '1.0.0',
npm: '3.10.10',
ares: '1.10.1-DEV',
http_parser: '2.7.0',
icu: '56.1',
modules: '48',
node: '6.11.2',
openssl: '1.0.2l',
uv: '1.11.0',
v8: '5.1.281.103',
zlib: '1.2.11' }
Also, the error message is completely different. The machine has ports 8080 and 8443 in use, but when I tired to shut down the applications using them, was not helpful.
That's because you didn't follow the steps.. as it says, before query.js u should enroll the admin and register user, then it works properly. And don't pay attention to "npm WARN fabcar#1.0.0 No repository field", it works well. Try the following:
$docker stop $(docker ps -a -q)
$docker ps -qa|xargs docker rm
$./startFabric.sh
$cd fabric-samples/fabcar/javascript
$node enrollAdmin.js
$npm install
$node registerUser.js
$node query.js
[