Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker-compose logs are only showing "Attaching to" and nothing else

After running "docker-compose up -d --force-recreate " + service_name via a python subprocess.call(), I then afterwards want to print out the logs from the docker-compose command using just a simple "docker-compose logs " + service_name. However, the logs will randomly only have "Attaching to" in them, rather than the full printout of logs. I am doing database changes to the containers, with first DDL changes and then DML changes. It turns out that the container is successfully being spun up and my changes made, and when I go to run the DML stage the container successfully upgrades and logs will print out, so it seems that the logs are getting stuck at "Attaching to" even though the container is continuing on to complete.

Why would docker-compose logs only be showing "Attaching to"?

Part of docker-compose file:

services:
  #
  # Components
  # ----------
  #
  agile:
    image: image
    ports:
    - 10031:8080
    environment:
    - JAVA_OPTS=-Xmx768m -Xss512k
    - ACTIVE_RELEASE_ID=${ACTIVE_RELEASE_ID}
    - CACHE_HOST=localdocker
    - CODE_DROP_ID=${CODE_DROP_ID}
    - ENVIRONMENT_TYPE=side
    - EUREKA_HOST=localdocker
    - KV_STORE_ADDRESS=localdocker:8500
    - KV_STORE_HOST=localdocker
    - KV_STORE_PORT=8500
    - KV_STORE_TYPE=remote
    - MESSAGING_HOST=localdocker
    - SEARCH_HOST=localdocker
    - SPRING_CLOUD_CONSUL_CONFIG_ENABLED=true
    - VIRTUAL_HOST=localdocker
    extra_hosts:
    - localdocker:${LOCALDOCKER_HOSTNAME}
    logging:
      driver: fluentd
      options:
        tag: docker
        env: NodeHostName,NodeID,Service,ServiceLabels,Task,TaskSlot,TaskID,TZ
        fluentd-address: ${LOCALDOCKER_HOSTNAME}:24224
        fluentd-async-connect: "true"

That is one of roughly 40 components that are being built. I am using Ansible to do asynchronous running of my commands.

like image 908
AGomez Avatar asked Aug 15 '19 16:08

AGomez


People also ask

How do I get full docker logs?

First of all, to list all running containers, use the docker ps command. Then, with the docker logs command you can list the logs for a particular container. Most of the time you'll end up tailing these logs in real time, or checking the last few logs lines.

Where do docker compose logs go?

Using Default Log File By default, Docker stores log files in a dedicated directory on the host using the json-file log driver. The log file directory is /var/lib/docker/containers/<container_id> on the host where the container is running.

Can I access the logs of the docker container?

The docker logs command shows information logged by a running container. The docker service logs command shows information logged by all containers participating in a service. The information that is logged and the format of the log depends almost entirely on the container's endpoint command.


3 Answers

My problem when facing a blank Attaching to message:

Since I had started the app with docker-compose -p my-fancy-name up -d, to receive the logs for this, I also had to pass the same -p flag:

docker-compose -p my-fancy-name logs -f

like image 106
panepeter Avatar answered Oct 18 '22 02:10

panepeter


I had the same problem - in my case, the problem was simply solved by cd into the directory where the docker-compose file is. Then docker-compose logs -f again.

like image 38
l001d Avatar answered Oct 18 '22 01:10

l001d


It is Attaching to the container(which name of that is give in the compose file) from the image which is built through the docker-file. there is a error with container and images by the way of mismatched the details as names of containers and images while in UP ...

like image 1
MathanKumar Avatar answered Oct 18 '22 01:10

MathanKumar