0

Service won't be listed in docker-compose ps when service name changes in docker-compose file lets say from redis to redisabc like below. Additionally docker creates it as a container, it can be seen when docker ps executed.

I restarted docker desktop and also made reboot to machine nothing changed.

My docker-compose file version is 3.6 enter image description here

  redisabc:
   container_name: redis
   image: redis
   command: [ "redis-server", "--protected-mode", "no" ]
   hostname: redis
   restart: always
   ports:
    - 6379:6379
   networks:
    - backend

as you see there is no service called redisabc when typed docker-compose ps enter image description here

but it stays as container (docker ps result) enter image description here

and this is the way I create docker-compose file enter image description here

If I change back the service name redisabc to redis once again everything works as expected enter image description here

IMPORTANT EDIT: I tested everything with another computer and no problem is shown. I wonder is there any caching mechanism for services on docker that I can flush all? I'm really confused about what's going on.

2
  • Should you be using docker service ls instead docker-compose ps? maybe its a typo, Mar 28, 2019 at 13:46
  • I did, docker service ls did not work, it says another thing: Error response from daemon: This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again. Mar 28, 2019 at 13:52

2 Answers 2

1

I've found the exact incident after trying almost everything (lots of things from docker system prune --volumes to uninstalling docker machine etc)

I had 2 different docker files named base-docker-compose.yml and docker-compose.yml. During the service creation I was calling docker-compose through base-docker-compose.yml file. Having created services I was doing docker-compose ps without base-docker-compose.yml file although base-docker-compose.yml is used while execution. Then I was doing docker-compose ps to list the whole up services. This was the mistake I made, I had to docker-compose -f base-docker-compose.yml ps.

0

I'll rewrite my answer cause I think I wasn't of much help.

Reviewing all the information I've replicated your setting at home with the following:

docker-compose.yml:

version: '3'
services:
  redisabc:
    image: "redis"
    command: [ "redis-server", "--protected-mode", "no" ]
    hostname: redis
    restart: always
    ports:
      - 6379:6379

Then I started it:

# docker-compose up
Creating docker_redisabc_1 ... done
Attaching to docker_redisabc_1
redisabc_1  | 1:C 28 Mar 2019 21:23:43.775 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redisabc_1  | 1:C 28 Mar 2019 21:23:43.775 # Redis version=5.0.3, bits=64, commit=00000000, modified=0, pid=1, just started
redisabc_1  | 1:C 28 Mar 2019 21:23:43.775 # Configuration loaded
redisabc_1  | 1:M 28 Mar 2019 21:23:43.776 * Running mode=standalone, port=6379.
redisabc_1  | 1:M 28 Mar 2019 21:23:43.776 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redisabc_1  | 1:M 28 Mar 2019 21:23:43.776 # Server initialized
redisabc_1  | 1:M 28 Mar 2019 21:23:43.776 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redisabc_1  | 1:M 28 Mar 2019 21:23:43.776 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redisabc_1  | 1:M 28 Mar 2019 21:23:43.776 * Ready to accept connections

The output from ps:

# docker-compose ps
      Name                     Command               State           Ports         
-----------------------------------------------------------------------------------
docker_redisabc_1   docker-entrypoint.sh redis ...   Up      0.0.0.0:6379->6379/tcp

The service name it's been used.

3
  • My concern is not related to having swarm at this point. Docker compose does not create service if I change the service name as I explained above, it is enormously ridiculous but what happens right now is this Mar 28, 2019 at 20:23
  • I've tried to replicate your problem but it looks to be working properly. Mar 28, 2019 at 21:32
  • same here, I have tried it also on another machine and it works. I'm gonna remove docker desktop and reinstall again Mar 29, 2019 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.