container exited with code 100 while making mongodb container up - mongodb

I am trying to making it up mongodb container but i am getting error
Starting v2_mongodb ... done
Starting rockmongo_v2 ... done
Attaching to v2_mongodb, rockmongo_v2
v2_mongodb | Starting mongod...
v2_mongodb exited with code 100
Here is the content of docker-compose.yml file and output of docker ps
version: '2'
services:
v2_db:
image: sameersbn/mongodb:latest
container_name: "v2_mongodb"
ports:
- "27017:27017"
volumes:
- ./data/db:/data/db:rw
- ./data/db:/var/lib/mongodb:rw
environment:
- MONGO_DATA_DIR=/data/db
command: mongod --verbose --smallfiles --dbpath=/data/db # --quiet
rockmongo_v2:
image: javierjeronimo/rockmongo:latest
container_name: "rockmongo_v2"
ports:
- "27118:80"
links:
- v2_db:mongo
depends_on:
- v2_db
docker ps output
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
94794d6f3ff1 javierjeronimo/rockmongo:latest "/bin/sh -c 'service…" 38 minutes ago Up About a minute 0.0.0.0:27118->80/tcp rockmongo_v2
bd4ed92796db sameersbn/mongodb:latest "/sbin/entrypoint.sh…" 38 minutes ago Exited (100) About a minute ago v2_mongodb
I am not able to get the clue what can be the possible cause of above error?

List your volume links:
docker volumes ls
Delete the volumes: (In my case this freed up about 29.35 Gig)
docker volumes prune

Related

manifest unknown error adding psql under docker

I make in docker php/postgres / phppgadmin and I need to add psql to my project to upload my sql dumps.
I found this https://hub.docker.com/r/softwareplant/psql and added it to my project, but running build command I got error :
docker-compose up -d --build
...
Sccessfully built 3b0700d7bed8
Successfully tagged lprodsdocker_web:latest
Pulling psql (softwareplant/psql:latest)...
ERROR: manifest for softwareplant/psql:latest not found: manifest unknown: manifest unknown
My docker-compose.yml :
version: '3'
services:
web:
build:
context: ./web # directory of web/Dockerfile.yml
dockerfile: Dockerfile.yml
environment:
- APACHE_RUN_USER=#1000
# - APACHE_RUN_USER=www-data
container_name: lprods_web
volumes:
- ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
ports:
- 8086:80
working_dir: ${APP_PTH_CONTAINER}
db:
image: postgres:9.6.10-alpine
container_name: lprods_db
ports:
- '5433:5432'
restart: always
environment:
POSTGRES_USER: 'postgres'
POSTGRES_PASSWORD: '1'
POSTGRES_DB: 'wprods'
volumes:
- ./init:/docker-entrypoint-initdb.d/
phppgadmin:
image: dockage/phppgadmin:latest
environment:
- PHP_PG_ADMIN_SERVER_HOST=db
- PHP_PG_ADMIN_SERVER_PORT=5432
- PHP_PG_ADMIN_SERVER_DEFAULT_DB=postgres
container_name: lprods_phppgadmin
restart: always
ports:
- 8087:80
- "443:443"
links:
- db
psql:
image: softwareplant/psql
environment:
- PHP_PG_ADMIN_SERVER_HOST=db
- PHP_PG_ADMIN_SERVER_PORT=5432
- PHP_PG_ADMIN_SERVER_DEFAULT_DB=postgres
container_name: lprods_phppgadmin
restart: always
ports:
- 8087:80
- "443:443"
links:
- db
composer:
image: composer:1.6
container_name: lprods_composer
volumes:
- ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
working_dir: ${APP_PTH_CONTAINER}
command: composer install --ignore-platform-reqs
Which way is correct ? On https://hub.docker.com there is such image...
Is it invalid ? Can you advice some other decision ?
MODIFIED :
Next I try
https://hub.docker.com/r/governmentpaas/psql
Provides psql Postgres client.
description seems like what I need : to upload dump into postgres db
In docker-compose.yml I added item :
psql:
image: governmentpaas/psql
environment:
- PHP_PG_ADMIN_SERVER_HOST=db
- PHP_PG_ADMIN_SERVER_PORT=5432
- PHP_PG_ADMIN_SERVER_DEFAULT_DB=postgres
container_name: lprods_psql
restart: always
ports:
- "8088:80"
- "444:444"
links:
- db
and it was installed ok and I see this container in hosting OS:
lprods_docker$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a3342c0b0df4 dockage/phppgadmin:latest "/sbin/entrypoint ap" 16 minutes ago Up 16 minutes 0.0.0.0:443->443/tcp, 0.0.0.0:8087->80/tcp lprods_phppgadmin
3ffa2823257a governmentpaas/psql "/bin/sh" 16 minutes ago Restarting (0) 42 seconds ago lprods_psql
7071eaf067d6 lprodsdocker_web "docker-php-entrypoi" 17 minutes ago Up 16 minutes 0.0.0.0:8086->80/tcp lprods_web
4372e269daf8 postgres:9.6.10-alpine "docker-entrypoint.s" 17 minutes ago Up 16 minutes 0.0.0.0:5433->5432/tcp lprods_db
But entering bash container no psql command found :
# uname -a
Linux 7071eaf067d6 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64 GNU/Linux
root#7071eaf067d6:/var/www/lprods_docker_root# whereis psql
# psql -v
bash: psql: command not found
Is it image I need ? If yes, how to use it ?
You have to specify the tag of the image, e.g.:
version: '3'
services:
[...]
psql:
image: softwareplant/psql:dev-jira7
[...]

Prisma, MongoDB, Docker "request to http://localhost:4466/ failed, reason: connect ECONNREFUSED 127.0.0.1:4466"

After I launch my docker-compose up command, everything starts up and I run prisma deploy which also works fine, yet my application still returns the above error. I have been trying to find a solution to this for days, and there is nothing helpful online, and the few similar questions have been closed or ignored. I would appreciate getting help with this issue.
Here is my docker-compose.yml file:
version: '3'
services:
prisma:
env_file:
- .env
image: prismagraphql/prisma:1.34
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
databases:
default:
connector: mongo
uri: ${MONGODB_URI}
host: host.docker.internal
JWT_SECRET: ${JWT_SECRET}
mongo:
env_file:
- .env
image: mongo:3.6
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGODB_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${MONGODB_PASSWORD}
ports:
- "27017:27017"
volumes:
- mongo:/var/lib/mongo
web:
env_file:
- .env
build: .
volumes:
- .:/usr/app/
- /usr/app/node_modules
ports:
- "4000:4000"
environment:
DATABASE_URL: ${MONGODB_URI}
volumes:
mongo:
My Dockerfile:
FROM node:8.16.0-alpine
WORKDIR /usr/app
COPY package.json .
RUN npm install --quiet
COPY . .
ENV DOCKERIZE_VERSION v0.6.0
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
CMD dockerize -wait tcp://mongo:27017 -wait tcp://prisma:4466 -timeout 60m npm start
My prisma.yml:
endpoint: http://localhost:4466
datamodel:
- db/types.prisma
- db/enums.prisma
databaseType: document
generate:
- generator: javascript-client
output: ./generated/prisma-client/
My prisma deploy command works, and it generates the mongo database, but when I try to query my application at localhost:4000, it looks like this and returns this error:
request to http://localhost:4466/ failed, reason: connect ECONNREFUSED 127.0.0.1:4466
But when I navigate to localhost:4466/_admin, the database is all set up fine and shows the three tables that should be there.
I checked if anything is running localhost:4466 by issuing this command: lsof -i :4466, and I can see that docker started up correctly.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
com.docke 5923 sguduguntla 24u IPv4 0x89ea943c9b98ff09 0t0 TCP *:4466 (LISTEN)
com.docke 5923 sguduguntla 25u IPv6 0x89ea943c87111549 0t0 TCP localhost:4466 (LISTEN)
When I run docker ps, you can also see the following output with the three images:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fa70fae37f10 prismagraphql/prisma:1.34 "/bin/sh -c /app/sta…" 35 minutes ago Up 31 minutes 0.0.0.0:4466->4466/tcp decal-board-graphql-server_prisma_1
d64b9f6dcd29 decal-board-graphql-server_web "docker-entrypoint.s…" 35 minutes ago Up 31 minutes 0.0.0.0:4000->4000/tcp decal-board-graphql-server_web_1
6f7dda5e58a0 mongo:3.6 "docker-entrypoint.s…" 35 minutes ago Up 31 minutes 0.0.0.0:27017->27017/tcp decal-board-graphql-server_mongo_1

Cannot connect to mongo docker from another docker

After looking this and this and this post, I couldn't connect to mongo from another docker.
This is a part of my DockerFile:
FROM ubuntu:16.04
...
WORKDIR /code
# Install project requirements
RUN pip3 install -r requirements.pip
ADD . /code
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/code/supervisord.conf"]
In my telegram service I am connecting to mongo like this:
register_connection(
alias='main',
name='new_tetabot',
host='mongo',
port=27017
)
And this is my docker-compose.yml file:
version: '3'
services:
telegram:
hostname: nh-11
build: .
ports:
- "9001:9001"
- "5555:5555"
extra_hosts:
postgresql: 127.0.0.1
mongo: 127.0.0.1
redis: 127.0.0.1
es: 127.0.0.1
broker: 127.0.0.1
volumes:
- /root/telegram_logs:/root/telegram_logs
- /home/crawler/telegram/sessions:/root/crawler/telegram/sessions
- /root/downloads:/root/downloads
- /root/images:/root/images
restart:
always
depends_on:
- mongo
- redis
links:
- mongo
- redis
redis:
image: "redis:latest"
ports:
- "6379:6379"
expose:
- "6379"
mongo:
image: "mongo:4"
ports:
- "27017:27017"
expose:
- "27017"
When I use docker-compose up I get Failed to connect to mongo port 27017: Connection refused. But I have telnet from localhost (outside of docker) to 127.0.0.1 on port 27017.
My docker-compose version is docker-compose version 1.23.2, build 1110ad01 and when I run docker-compose up the result of docker ps is
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dfa23e7d07dd telegram_telegram "/bin/sh -c 'curl \"m…" 2 minutes ago Restarting (7) 11 seconds ago telegram_telegram_1
74d875f3828c mongo:4 "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:27017->27017/tcp telegram_mongo_1
6ee448c1cc30 redis:latest "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:6379->6379/tcp telegram_redis_1
You need to remove extra_hosts from your docker-compose.yml when using links. The telegram container is unable to resolve the correct address for mongo because it was overrided to 127.0.0.1.

How to use docker-compose to setup a mongodb with pymonogo app?

I am trying to spin up a python application with mongodb server using docker-composer, but I get the following error:
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused
I really don't understand what am I missing in my setup:
version: '3.6'
services:
web:
build: .
ports:
- "5000:5000"
- "9000:9000"
links:
- db
db:
image: mongo:latest
container_name: "mongodb"
ports:
- 27017:27017
command: mongod --smallfiles # --quiet
redis:
image: "redis:alpine"
I am not sure why I can't connect to the server which seems to be up (docker ps):
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fb5a00bb8867 composedir_web "python app.py" 20 seconds ago Up 19 seconds 0.0.0.0:5000->5000/tcp, 0.0.0.0:9000->9000/tcp composedir_web_1
56aeae245ad5 mongo:latest "docker-entrypoint.s…" 14 minutes ago Up 20 seconds 0.0.0.0:27017->27017/tcp mongodb
51c64650bab8 redis:alpine "docker-entrypoint.s…" 14 minutes ago Up 21 seconds 6379/tcp composedir_red
You need to configure the python application to connect mongo on db:27017 instead of localhost:27017

Docker container shuts down giving 'data directory has wrong ownership' error when executed in windows 10

I have my docker installed in Windows. I am trying to install this application. It has given me the following docker-compose.yml file:
version: '2'
services:
web:
build:
context: .
dockerfile: Dockerfile-nginx
ports:
- "8085:80"
networks:
- attendizenet
volumes:
- .:/usr/share/nginx/html/attendize
depends_on:
- php
php:
build:
context: .
dockerfile: Dockerfile-php
depends_on:
- db
- maildev
- redis
volumes:
- .:/usr/share/nginx/html/attendize
networks:
- attendizenet
php-worker:
build:
context: .
dockerfile: Dockerfile-php
depends_on:
- db
- maildev
- redis
volumes:
- .:/usr/share/nginx/html/attendize
command: php artisan queue:work --daemon
networks:
- attendizenet
db:
image: postgres
environment:
- POSTGRES_USER=attendize
- POSTGRES_PASSWORD=attendize
- POSTGRES_DB=attendize
ports:
- "5433:5432"
volumes:
- ./docker/pgdata:/var/lib/postgresql/data
networks:
- attendizenet
maildev:
image: djfarrelly/maildev
ports:
- "1080:80"
networks:
- attendizenet
redis:
image: redis
networks:
- attendizenet
networks:
attendizenet:
driver: bridge
All the installation goes well, but the PostgreSQL container stops after starting for a moment giving following error.
2018-03-07 08:24:47.927 UTC [1] FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
2018-03-07 08:24:47.927 UTC [1] HINT: The server must be started by the user that owns the data directory
A simple PostgreSQL container from Docker Hub works smoothly, but the error occurs when we try to attach a volume to the container.
I am new to docker, so please ignore usage of terms wrongly.
This is a documented problem with the Postgres Docker image on Windows [1][2][3][4]. Currently, there doesn't appear to be a way to correctly mount Windows directories as volumes. You could instead use a persistent Docker volume, for example:
db:
image: postgres
environment:
- POSTGRES_USER=attendize
- POSTGRES_PASSWORD=attendize
- POSTGRES_DB=attendize
ports:
- "5433:5432"
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- attendizenet
volumes:
pgdata:
Other things that didn't work:
Set PGDATA to a subdirectory (See PGDATA Setting)
environment:
- PGDATA=/var/lib/postgresql/data/mnt
volumes:
- ./pgdata:/var/lib/postgresql/data
Use a Bind Mount (docker-compose 3.2)
volumes:
- type: bind
source: ./pgdata
target: /var/lib/postgresql/data
Running as POSTGRES_USER=root
More Information:
GitHub
data directory "/var/lib/postgresql/data" has wrong ownership
Docker Forums
postgresql-data-pgdata-has-wrong-ownership
postgres-to-work-on-persistent-windows-mount
Please refer reinierkors' answer from here. The answer is as follows copied as is from the link here for reader's convenience and works for me
I solved this by mapping my local volume one directory below the one Postgres needs:
version: '3'
services:
postgres:
image: postgres
restart: on-failure
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
- PGDATA=/var/lib/postgresql/data/pgdata
- POSTGRES_DB=postgres
volumes:
- ./postgres_data:/var/lib/postgresql
ports:
- 5432:5432
I was having the same issue after downgrading my Docker from WSL 2 to WSL 1 and what Thomas Taylor's pertaining, I solved the issue by using named volume.
version: '3.8'
services:
postgres:
image: timescale/timescaledb:latest-pg12
...
volumes:
- pgdata:/var/lib/postgresql/data
...
volumes:
pgdata:
Map the local volume (e.g. C:\docker\pgdata) to one level (one directory) above what PostgreSQL needs. You can also do it from command line when starting the docker:
docker run -itd -e POSTGRES_USER=pguser -e POSTGRES_PASSWORD=pgpasswd \
-e PGDATA=/var/lib/postgresql/data/pgdata -p 5432:5432 \
-v c:\docker\pgdata:/var/lib/postgresql --name postgresql postgres
I met this issue when re-installed docker and used wsl-1 backend.
solution: switch docker to wsl-2 backend.
Even i had the problem i had to copy the data dir at regular intervals.
docker cp <container-name>:/var/lib/postgresql/data C:/docker/volumes/postgres
Owner for the data folder in postgres inside the container is Postgres user. Your current user may not have access privilege in the mounted folder. You need to give all permissions according to the requirements by given command below :
chmod 777 ./docker/pgdata
If this command is not helping to resolve this issue please refer the following link to do the user mapping from inside the container to outside the container.
https://docs.docker.com/engine/security/userns-remap/#prerequisites