Docker container unhealthy but no error in the logs - docker

I am using the official docker-compose file of airflow to spin it up.
Some of my containers seem unhealthy:
34d8698d67e7 apache/airflow:2.0.2 "/usr/bin/dumb-init …" 31 minutes ago Up 28 minutes (unhealthy) 0.0.0.0:5555->5555/tcp, :::5555->5555/tcp, 8080/tcp airflow_flower_1
a291cf238b9f apache/airflow:2.0.2 "/usr/bin/dumb-init …" 31 minutes ago Up 29 minutes 8080/tcp airflow_airflow-init_1
fdb20e9152f3 apache/airflow:2.0.2 "/usr/bin/dumb-init …" 31 minutes ago Up 29 minutes (unhealthy) 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp airflow_airflow-webserver_1
abf5a16aa846 apache/airflow:2.0.2 "/usr/bin/dumb-init …" 31 minutes ago Up 29 minutes 8080/tcp airflow_airflow-worker_1
f6dc352f407b apache/airflow:2.0.2 "/usr/bin/dumb-init …" 31 minutes ago Up 28 minutes 8080/tcp airflow_airflow-scheduler_1
12dfc71e518f redis:latest "docker-entrypoint.s…" 31 minutes ago Up 29 minutes (healthy) 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp airflow_redis_1
However the logs of one of them for example do not seem very informative.
# docker logs -f fdb20e9152f3
WARNING! You should run the image with GID (Group ID) set to 0
even if you use 'airflow' user (UID=50000)
You started the image with UID=50000 and GID=50000
This is to make sure you can run the image with an arbitrary UID in the future.
See more about it in the Airflow's docker image documentation
http://airflow.apache.org/docs/docker-stack/entrypoint
BACKEND=postgresql+psycopg2
DB_HOST=my-db-endpoint
DB_PORT=5432
WARNING! You should run the image with GID (Group ID) set to 0
even if you use 'airflow' user (UID=50000)
You started the image with UID=50000 and GID=50000
This is to make sure you can run the image with an arbitrary UID in the future.
See more about it in the Airflow's docker image documentation
http://airflow.apache.org/docs/docker-stack/entrypoint
BACKEND=postgresql+psycopg2
DB_HOST=my-db-endpoint
DB_PORT=5432
Regardless of any airflow - specific issues, how can I check docker - wise what's going on?
Docker seems to be aware of a couple of containers not being healty.
edit: both failing containers have the healtcheck condition
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:5555/"]
and
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8080/"]
that seems to be failing by looking into their inspect output
Failed to connect to localhost port 8080: Connection refused
but I cannot pinpoint what is causing the failure.
edit: I have tried following the instructions to start the init service first as well
# docker-compose up airflow-init
Starting airflow_redis_1 ... done
Starting airflow_airflow-init_1 ... done
Attaching to airflow_airflow-init_1
airflow-init_1 | BACKEND=postgresql+psycopg2
airflow-init_1 | DB_HOST=my-db-endpoint
airflow-init_1 | DB_PORT=5432
but it never exits, it prints the above message and that's it...

I ran into similar issue and it was docker volume causing the issue. As I was running lots of containers on my mac, there wasn;t enough disk space. I managed to fixed this issue my pruning the docker volume.
docker volume prune
This will remove any unused volume on your mac book. Before running this command please check if you got any useful data.

For docker-compose, from the entrypoint, the default value of group id is 0.
"${AIRFLOW_UID:-50000}:${AIRFLOW_GID:-0}"
Edit your docker-compose.yaml file or ad ass env.sh file in your Airflow project repository.

It does seems to be an error due to less memory allocated to docker for running this image, try to increase the resources available to docker and see the magic

I ran into similar issue and the healthchecks were "causing" this. I was running them using default container's user.
Just to give a try, I changed the healthckeck command to start using airflow user instead, as follow:
$ runuser -u airflow -- <healthckeck command>
And it solved. I'm gonna change the user whom runs docker compose up to airflow from now on.

Related

Docker save: No such image

When i run docker save nifi > nifi_backup.tar i get
Error response from daemon: No such image: nifi
When i run docker ps -a i got
$docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a8796cbf6cb1 apache/nifi:1.9.2 "../scripts/start.sh" 11 months ago Exited (0) 33 minutes ago nifi
f4ecf6ca0d16 apache/nifi "../scripts/start.sh" 12 months ago Exited (0) 12 months ago nervous_poincare
9a68c235bb3a apache/nifi "../scripts/start.sh" 12 months ago Exited (0) 12 months ago jolly_mendel
d608287fe560 superset_superset "/entrypoint.sh" 2 years ago Up 27 hours (healthy) 0.0.0.0:8088->8088/tcp, :::8088->8088/tcp superset_superset_1
fcea620b1983 postgres:10 "docker-entrypoint.s…" 2 years ago Up 27 hours 0.0.0.0:5433->5432/tcp, :::5433->5432/tcp superset_postgres_1
380782e0a024 redis:3.2 "docker-entrypoint.s…" 2 years ago Up 27 hours 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp superset_redis_1
Also, i cant start nifi image
if i run docker start nifi
it try to start about a minute, but then stop silently.
And there is no logs in result.
docker events says exit code = 0:
Maybe it has some relation for unavailable saving, so i inform about it too.
How to fix No such image in such a case?
Use the command docker images to see if there is an image named nifi. If not first build that image and than execute the command:
docker save nifi > nifi_backup.tar
It should not show the error No such image: nifi if the command docker images has an image named nifi.
As per documentation here, docker save command expects an image name, not a container. You're probably looking for docker export (export docs) command to achieve what you want.
The error about starting your container could be container-specific. As it exited already a year ago, maybe data is lost and the container cannot be started again. Using command docker events&, you can start the docker event listener in the background. This way you can obtain the hex value of this very start attempt and use it to search specific logs: docker logs <startId hex>. Maybe it can tell you more details about why the container did not properly start.

Docker stack deploy cannot deploy service to different node in swarm cluster

I am trying to deploy the application on multiple instances. On master node. after deployed application running the only master node. cannot deploy service different node in the docker swarm cluster.
here my docker-compose file
version: "3"
services:
mydb:
image: localhost:5000/mydb-1
environment:
TZ: "Asia/Colombo"
ports:
- 9042:9042
volumes:
- /root/data/cdb:/var/lib/cassandra
- /root/logs/cdb:/var/log/cassandra
command docker service scale mydb-1_mydb=5
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7fxxxxxxxx7 localhost:5000/mydb-1:latest "docker-entrypoint.sh" 16 seconds ago Up 5 seconds 7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp mydb-1_mydb.2.q77i258vn2xynlgein9s7tdpb
34fcxxxx14bd localhost:5000/mydb-1:latest "docker-entrypoint.sh" 16 seconds ago Up 4 seconds 7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp mydb-1_mydb.1.s2mzitj8yzb0zo7spd3dmpo1j
9axxxx1efb localhost:5000/mydb-1:latest "docker-entrypoint.sh" 16 seconds ago Up 8 seconds 7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp mydb-1_mydb.3.zgyev3p4qdg7hf7h67oeedutr
f14xxxee59 localhost:5000/mydb-1:latest "docker-entrypoint.sh" 16 seconds ago Up 2 seconds 7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp mydb-1_mydb.4.r0themodonzzr1izdbnppd5bi
e3xxx16d localhost:5000/mydb-1:latest "docker-entrypoint.sh" 16 seconds ago Up 6 seconds 7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp mydb-1_mydb.5.bdebi4
all running only master-node. Does anyone know the issue?
Your image appears to be locally built with a name that cannot be resolved in other nodes (localhost:5000/mydb-1). In swarm, images should be pushed to a registry, and that registry needs to be accessible by all nodes. You can run your own registry service on your own node, there's a docker image, or you can push to docker hub. If the registry is private, you also need to perform a docker login on the node running the stack deploy and include registry credentials in that deploy, e.g.
docker stack deploy -c compose.yml --with-registry-auth stack-name
Thanks. I find the issue and fixed.
volumes:
- /root/data/cdb:/var/lib/cassandra
- /root/logs/cdb:/var/log/cassandra
If you bind mount a host path into your service’s containers, the path must exist on every swarm node.
docker service scale zkr_zkr=2
after scale-up service running my node
root#beta-node-1:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f9bxxx15861 localhost:5000/zookeeper:latest "/docker-entrypoint.…" 40 minutes ago Up 40 minutes 2181/tcp, 2888/tcp, 3888/tcp, 8080/tcp zkr_zkr.3.qpr8qp5y
01dxxxx64bc localhost:5000/zookeeper:latest "/docker-entrypoint.…" 40 minutes ago Up 40 minutes 2181/tcp, 2888/tcp, 3888/tcp, 8080/tcp zkr_zkr.1.g2uee5j

Docker scale with deterministic port binding

I would like to scale a wildfly container having exposed multiple ports with deterministic results.
docker-compose.yml
version: '3'
services:
wildfly-server:
build:
context: .
dockerfile: Dockerfile
args:
admin_user: admin
admin_password: admin
deploy:
resources:
limits:
memory: 1.5G
cpus: "1.5"
restart: always
ports:
- "8000-8099:8080"
- "8100-8199:9990"
- "8200-8299:8787"
expose:
- "8080"
- "9990"
- "8787"
Dockerfile
FROM jboss/wildfly:16.0.0.Final
# DOCKER ENV VARIABLES
ENV WILDFLY_HOME /opt/jboss/wildfly
ENV STANDALONE_DIR ${WILDFLY_HOME}/standalone
ENV DEPLOYMENT_DIR ${STANDALONE_DIR}/deployments
ENV CONFIGURATION_DIR ${STANDALONE_DIR}/configuration
RUN ${WILDFLY_HOME}/bin/add-user.sh ${admin_user} ${admin_password} --silent
# OPENING DEBUG PORT
RUN rm ${WILDFLY_HOME}/bin/standalone.conf
ADD standalone.conf ${WILDFLY_HOME}/bin/
# SET JAVA ENV VARS
RUN rm ${CONFIGURATION_DIR}/standalone.xml
ADD standalone.xml ${CONFIGURATION_DIR}/
Command to start
docker-compose up --build --force-recreate --scale wildfly-server=10
It almost works as I want to, but there is some port discrepancy. When I create the containers, I want them to have incremental ports for each container to be exposed as follows:
machine_1 8001, 8101, 82001
machine_2 8002, 8102, 82002
machine_3 8003, 8103, 82003
But what I get as a result is not deterministic and looks like this:
machine_1 8001, 8102, 82003
machine_2 8002, 8101, 82001
machine_3 8003, 8103, 82002
The problem is that every time I run the compose up command, the ports are different for each container.
Example output:
CONTAINER ID COMMAND CREATED STATUS PORTS NAMES
0232f24fbca4 "/opt/jboss/wildfly/…" 5 minutes ago Up 5 minutes 0.0.0.0:8028->8080/tcp, 0.0.0.0:8231->8787/tcp, 0.0.0.0:8126->9990/tcp wildfly-server_7
13a6a365a552 "/opt/jboss/wildfly/…" 5 minutes ago Up 5 minutes 0.0.0.0:8031->8080/tcp, 0.0.0.0:8230->8787/tcp, 0.0.0.0:8131->9990/tcp wildfly-server_10
bf8260d9874d "/opt/jboss/wildfly/…" 5 minutes ago Up 5 minutes 0.0.0.0:8029->8080/tcp, 0.0.0.0:8228->8787/tcp, 0.0.0.0:8129->9990/tcp wildfly-server_6
3d58f2e9bdfe "/opt/jboss/wildfly/…" 5 minutes ago Up 5 minutes 0.0.0.0:8030->8080/tcp, 0.0.0.0:8229->8787/tcp, 0.0.0.0:8130->9990/tcp wildfly-server_9
7824a73a09f5 "/opt/jboss/wildfly/…" 5 minutes ago Up 5 minutes 0.0.0.0:8027->8080/tcp, 0.0.0.0:8227->8787/tcp, 0.0.0.0:8128->9990/tcp wildfly-server_3
85425462259d "/opt/jboss/wildfly/…" 5 minutes ago Up 5 minutes 0.0.0.0:8024->8080/tcp, 0.0.0.0:8224->8787/tcp, 0.0.0.0:8124->9990/tcp wildfly-server_2
5be5bbe8e577 "/opt/jboss/wildfly/…" 5 minutes ago Up 5 minutes 0.0.0.0:8026->8080/tcp, 0.0.0.0:8226->8787/tcp, 0.0.0.0:8127->9990/tcp wildfly-server_8
2512fc0643a3 "/opt/jboss/wildfly/…" 5 minutes ago Up 5 minutes 0.0.0.0:8023->8080/tcp, 0.0.0.0:8223->8787/tcp, 0.0.0.0:8123->9990/tcp wildfly-server_5
b156de688dcb "/opt/jboss/wildfly/…" 5 minutes ago Up 5 minutes 0.0.0.0:8025->8080/tcp, 0.0.0.0:8225->8787/tcp, 0.0.0.0:8125->9990/tcp wildfly-server_4
3e9401552b0a "/opt/jboss/wildfly/…" 5 minutes ago Up 5 minutes 0.0.0.0:8022->8080/tcp, 0.0.0.0:8222->8787/tcp, 0.0.0.0:8122->9990/tcp wildfly-server_1
Question
Is there any way to make the port distribution deterministic? Like disable parallel running to have serial checks on the available ports or any other method? The only alternative I found is to have a yml template and generate all the necessary files (like 10 if I need 10 containers etc). Are there any alternative solutions?
No, you cannot currently (10/14/19) make the port selection deterministic in the docker-compose file. This behavior was requested in Github issues #722 and #1247, but those issues were closed without the issue having been implemented.
If you want to semi-dynamically scale an application like it sounds like you do, then you'll need to solve this another way. Your .yml templating idea sounds like the cleanest solution IMO.
Are you sure you need the ports to be deterministic? If you use a reverse proxy like nginx that listens on one host port and balances the load between all of your docker containers, would that work for your use case? Setting up an nginx load balancer in a docker container is pretty straightforward. I suggest you look into that, and if you still need a deterministic way for a caller to know the service's port so it can send a request to a specific server repeatedly, then go with your .yml templating solution or some kind of service discovery process separate from the docker-compose configuration.
You could do this using variable substitution:
yaml:
...
ports:
${PORT}:8080
Then call docker with the specific ports:
for p in {8000..8099}; do
PORT=$p docker-compose ...
done

Why can't I go to localhost using Laradock?

I'm getting error: This page isn’t working
I ran the following command inside the Laradock directory yet it's not connecting when I go to localhost. docker-compose up -d nginx postgres
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
19433b191832 laradock_nginx "/bin/bash /opt/star…" 5 minutes ago Up 5 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp laradock_nginx_1
e7f68a9d841d laradock_php-fpm "docker-php-entrypoi…" 5 minutes ago Up 5 minutes 9000/tcp laradock_php-fpm_1
3c73fedff4aa laradock_workspace "/sbin/my_init" 5 minutes ago Up 5 minutes 0.0.0.0:2222->22/tcp laradock_workspace_1
eefb58598ee5 laradock_postgres "docker-entrypoint.s…" 5 minutes ago Up 5 minutes 0.0.0.0:5432->5432/tcp laradock_postgres_1
ea559a775854 docker:dind "dockerd-entrypoint.…" 5 minutes ago Up 5 minutes 2375/tcp laradock_docker-in-docker_1
docker-compose ps returns these results:
$ docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------------------------------
laradock_docker-in-docker_1 dockerd-entrypoint.sh Up 2375/tcp
laradock_nginx_1 /bin/bash /opt/startup.sh Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
laradock_php-fpm_1 docker-php-entrypoint php-fpm Up 9000/tcp
laradock_postgres_1 docker-entrypoint.sh postgres Up 0.0.0.0:5432->5432/tcp
laradock_workspace_1 /sbin/my_init Up 0.0.0.0:2222->22/tcp
Any help would be much appreciated.
I figured this out. I edited my docker-compose file volume to be /local/path/to/default.conf:/etc/nginx/sites-available
This is a problem because nginx looks for default.conf file but the volumes flag was setting sites-available as the file. I thought docker volume would symlink the file into the site-available directory not make it a file.
The correct volume syntax should be:
/local/path/to/default.conf:/etc/nginx/sites-available/default.conf

Ports not accessable

I installed docker and issues a 'docker swarm init' command.
I'm trying to launch a stack using the following command: docker stack deploy -c docker-compose.yml mystack
The docker-compose file can be found here, the first docker file here and the second here
The output of 'docker ps' is:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f582b3e8d33e tons/ip2country:latest "/bin/sh -c 'java -D…" 8 seconds ago Up 6 seconds 8080/tcp ip2flag_country-service.1.t5rvuqaw8tj7v20u0xo0dgy6x
bbf2c8304f1a tons/ip2flag:latest "/bin/sh -c 'java -D…" 10 seconds ago Up 8 seconds 8080/tcp ip2flag_app.1.z00gz8adj2yshpgimaw2o55d3
cbc7eaace4bf portainer/portainer "/portainer" 39 minutes ago Up 39 minutes 0.0.0.0:9000->9000/tcp portainer
The output of 'docker service ls' is:
ID NAME MODE REPLICAS IMAGE PORTS
ex51pyh1oyyo ip2flag_app replicated 1/1 tons/ip2flag:latest *:8080->8080/tcp
yhbt97lmjqan ip2flag_country-service replicated 1/1 tons/ip2country:latest
Since I'm running this on localhost I'd expect http://localhost:8080/ to return some sort of data. But it just times out. If I attach to the container and execute something like wget localhost:8080/some/path it works as expected. So the service is running and within the container listening to port 8080. However the port isn't exposed outside of dockers net. Further more I can add that launching with 'docker-compose up' works just fine too. But not with 'docker stack deploy'. Any clue about what I'm doing wrong?

Resources