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.
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.
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.
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.
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
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.
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 ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With