Unable to read mysql through Jyputer in docker containers (error: DatabaseError: 2005 (HY000): Unknown MySQL server host 'localhost:3306' (22)) - mysql

My code is as follows:
import mysql.connector
mydb = mysql.connector.connect(host="localhost:3306",user="root",password="example")
print("Connected")
Docker compose for mysql and jyputer files:
# Use root/example as user/password credentials
version: '3.1'
services:
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
AWS_ACCESS_KEY_ID: "A"
AWS_SECRET_ACCESS_KEY: "k"
adminer:
image: adminer
restart: always
ports:
- 8080:8080
jyputer:
version: "3"
services:
pyspark:
image: "jupyter/all-spark-notebook"
volumes:
- c:/code/pyspark-data:/home/jovyan
ports:
- 8888:8888
environment:
AWS_ACCESS_KEY_ID: "5H"
AWS_SECRET_ACCESS_KEY: "0oRBJk"
I have also created a network and kept all containers under one network, by using this command
docker network connect mynetwork 929cd60b08df
Error Received while execuitng in jyputer network:
DatabaseError: 2005 (HY000): Unknown MySQL server host 'localhost:3306' (22)
What have I tried:
mysql error 2005 - Unknown MySQL server host 'localhost'(11001)
127.0.0.1 localhost
this netry is already there in etc/hosts folder. Dont know what to do now

When you created a network you need to connect both containers
docker network create mynetwork
docker network connect mynetwork db_container_id
docker network connect mynetwork pyspark_container_id
Then get its config
docker network inspect mynetwork
It gives an IP addresses of this bridge network
[
{
"Name": "t11",
"Id": "bb203079ab3e48badacb3bb53181dd6871b2f60f22b4079729bc069e1739bbe0",
"Created": "2021-05-21T04:46:48.591105541Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.28.0.0/16",
"Gateway": "172.28.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"3ff678e8ddeb600b1af38a06dda053c8bf6544b136bfca91363379df1d40c69a": {
"Name": "t1_db_1",
"EndpointID": "deefd7c8a187b9513fd074f9632f961312a3bdaa8aa568be6223f3d301389808",
"MacAddress": "02:42:ac:1c:00:03",
"IPv4Address": "172.28.0.3/16",
"IPv6Address": ""
},
"9c95f68416586d3f1a87376a4a669df834d7b25eb22e3b3f33afb0ce1918d6cc": {
"Name": "t2_pyspark_1",
"EndpointID": "0fcbf15530f5b0a526c2036d26890e087f3becdd6eae1896e58a6a67efe2f676",
"MacAddress": "02:42:ac:1c:00:02",
"IPv4Address": "172.28.0.2/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
you need IP of db container, in this example it's 172.28.0.3
go with it
mydb = mysql.connector.connect(port="3306", host="172.28.0.3", user="root", password="example")
print("Connected")
cursor = mydb.cursor()
query = ("select 1;")
cursor.execute(query)
for r in cursor:
print(r)
cursor.close()

Related

Communication problems between two containers in the same network, mysql and spring boot

I'm having issues with the connection between two containers that are in the same network, one is mysql container and other container contains spring boot jar. I will paste here the relevant information:
These are the relevant network properties of mysql container:
"Networks": {
"my_network": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"f205465d5a7e",
"mysqldb"
]
}
"Ports": {
"3306/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "3307"
},
{
"HostIp": "::",
"HostPort": "3307"
}
],
"33060/tcp": null
}
This is the docker-compose file of my spring boot app:
version: '3.5'
services:
my_springboot_service:
container_name: my-springboot-container
hostname: my-springboot-container
image: my_springboot_image
restart: always
build: .
networks:
- my_network
environment:
MYSQL_HOST: mysqldb
MYSQL_PORT: 3306
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_DATABASE: spring_database
networks:
my_network:
external: true
name: my_network
Here is also the network configuration:
{
"Name": "my_network",
"Id": "4024f3611b1cf1526e44fa5663c32fcd86fba563983fd5a2d7a6298af5400d12",
"Created": "2023-01-18T01:57:27.921023955+01:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.20.0.0/16",
"Gateway": "172.20.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"a481e00d2903735b61020eb33cf8d41c6c61dada4843b89e99d1c131099a701e": {
"Name": "my-springboot-container",
"EndpointID": "4e4ffd82d0c96e22b0a1b1fc7be2391d9f29324049e6403727175a001acba385",
"MacAddress": "02:42:ac:14:00:03",
"IPv4Address": "172.20.0.3/16",
"IPv6Address": ""
},
"f205465d5a7e3bb4cae02d691c0058efc9e53efe93849270245462bc74f29ef3": {
"Name": "mysqldb",
"EndpointID": "272937b9776be7369915f50023c73e1c8a702a39863b57b49705019673f52868",
"MacAddress": "02:42:ac:14:00:02",
"IPv4Address": "172.20.0.2/16",
"IPv6Address": ""
}
}
}
As you can see, mysql container is on "my_network" and since his alias is "mysqldb", I'm trying to connect from the spring boot container with the URL:
jdbc:mysql://mysqldb:3306/spring_database
Both user and password for the database are good since I am able to connect to the database outside of the container and network.
But when I hit docker-compose up --build for my spring app, I get an exception
Unable to obtain connection from database: Communications link failure
Can anyone explain what could be the problem? Thanks in advance.

Why is my docker networks gateway IP unaccessible from my host OS

I am trying to get the following set up working:
My local machine OS = Linux
I am building a docker mysql container on this local machine
I plan to seed the database within the container, and then run tests locally (on my local Linux machine) against this container (which i will spin up on my linux machine too)
Unfortunately when running my tests and trying to connect to the container, the default bridge networks Gateway IP is inaccessible.
My docker-compose.yaml file is as follows
version: "3.4"
services:
integration-test-mysql:
image: mysql:8.0
container_name: ${MY_SQL_CONTAINER_NAME}
environment:
- MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
ports:
- "3306:3306"
volumes:
# - ./src/db:/usr/src/db #Mount db folder so we can run seed files etc.
- ./seed.sql:/docker-entrypoint-initdb.d/seed.sql
network_mode: bridge
healthcheck:
test: "mysqladmin -u root -p$MYSQL_ROOT_PASSWORD -h 127.0.0.1 ping --silent 2> /dev/null || exit 1"
interval: 5s
timeout: 30s
retries: 5
start_period: 10s
entrypoint: sh -c "
echo 'CREATE SCHEMA IF NOT EXISTS gigs;' > /docker-entrypoint-initdb.d/init.sql;
/usr/local/bin/docker-entrypoint.sh --default-authentication-plugin=mysql_native_password
"
When running docker network ls i see the following
docker network ls
NETWORK ID NAME DRIVER SCOPE
42a11ef835dd bridge bridge local
c7453acfbc98 host host local
48572c69755a integration_default bridge local
bd470f8620fd none null local
So the integration_default network was created. Then if i inspect this network
docker network inspect integration_default
[
{
"Name": "integration_default",
"Id": "48572c69755ae1bbc1448ab203a01d81be4300da12c97a9c4f1142872b878387",
"Created": "2022-09-28T00:48:20.504251612Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.27.0.0/16",
"Gateway": "172.27.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"79e897decb4f0ae5836c018d82e78997e8ac2f615b399362a307cc7f585c0875": {
"Name": "integration-test-mysql-host",
"EndpointID": "1f7798554029cc2d07f7ba44d057c489b678eac918f7916029798b42585eda41",
"MacAddress": "02:42:ac:1b:00:02",
"IPv4Address": "172.27.0.2/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "default",
"com.docker.compose.project": "integration",
"com.docker.compose.version": "2.7.0"
}
}
]
Comparing this to the default bridge
docker inspect bridge
[
{
"Name": "bridge",
"Id": "42a11ef835dd1b2aec3ecea57211bb2753e0ebd4a2a115ace8b7df3075e97d5a",
"Created": "2022-09-27T21:54:44.239215269Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
Interestingly running ping 172.17.0.1 on my Linux machine works fine but ping 172.27.0.1 fails to return anything
UPDATE
I have got it working now. By specifying network_mode: bridge in my docker compose file i was able to use the default bridge network which was accessible on my local machine as i mentioned.
However, i would like to know why creating my own network didn't work here. Does anyone know why this was the case?
Docker networks are meant to be hidden and you should let docker do its job unless there is a good reason for it.
The correct way to interract with a service is through its open ports. And those ports are mapped on the host so that talking to the host:port is like talking to the app inside the container.
So when you say that you can't ping your container from the host, it is because Docker does its job good. "Fixing" this breaks the isolation of the container and makes it available to other services that shouldn't have acccess to it.

Docker - MySQL Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306 [duplicate]

This question already has answers here:
ECONNREFUSED for Postgres on nodeJS with dockers
(7 answers)
Docker Compose wait for container X before starting Y
(20 answers)
Closed 12 months ago.
I'm trying to dockerize an app written in vuejs, nodejs, express and mysql from the tutorial https://github.com/bezkoder/vue-js-node-js-express-mysql. But my node app container encounter db connection issue as below:
Server is running on port 8080.
Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306
at /app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:123:19
at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:725:18)
at _drainQueueStep (/app/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/app/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (node:internal/timers:466:21)
My Dockerfile
FROM node
WORKDIR /app
COPY package.json .
RUN npm install
COPY . ./
ENV PORT 8080
EXPOSE $PORT
CMD ["node", "server.js"]
My docker-compose.yml
version: "3"
services:
vue-app:
build: .
ports:
- "8080:8080"
environment:
- PORT=8080
volumes:
- ./:/app
- /app/node_modules
mysql:
platform: linux/x86_64
image: mysql
# volumes:
# - /db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: testdb
MYSQL_USER: user
MYSQL_PASSWORD: 12345678
ports:
- "3306:3306"
db.config.js
module.exports = {
HOST: "localhost",
USER: "user",
PASSWORD: "12345678",
DB: "testdb",
dialect: "mysql",
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
}
};
I did tried changing the HOST from "localhost" to "mysql" - same as the service name in the docker-compose.yml hoping both containers could connect each other turns out getting the same error but with different ip instead.
Server is running on port 8080.
Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED 172.27.0.2:3306
at /app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:123:19
at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:725:18)
at _drainQueueStep (/app/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/app/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (node:internal/timers:466:21)
Here is my repo with dockerfile and docker-compose.yml added to the main project. https://github.com/Alex2Tacy/docker-nodeapp
Docker network inspect result:
[
{
"Name": "vuejs_default",
"Id": "546474b67f9a27cf6a944b7f95d1d2e7617e925a1f6b3b5a6d2ffb2f937039e9",
"Created": "2022-03-10T12:16:20.641870542Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.27.0.0/16",
"Gateway": "172.27.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"a77b8de2e7f0637c9b8c05af97f279e65600aed50321953a0b372ba0c7e591fc": {
"Name": "vuejs-mysql-1",
"EndpointID": "d6bb0b17688a784eb10e0cb292a78957071d5bfcb7ef93fb0dda899549825bd8",
"MacAddress": "02:42:ac:1b:00:02",
"IPv4Address": "172.27.0.2/16",
"IPv6Address": ""
},
"f57cd86543bfd2da9aaa47c687a8bc79c69d3f5cc6d31b1bc8ccbf975a47212a": {
"Name": "vuejs-vue-app-1",
"EndpointID": "8fb044889b1feb5deb9566a5cab7f94896ba0595bae1259fdf8fff1eb3d27f66",
"MacAddress": "02:42:ac:1b:00:03",
"IPv4Address": "172.27.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "default",
"com.docker.compose.project": "vuejs",
"com.docker.compose.version": "2.2.3"
}
}
]
The database hostname needs to be the service name rather than localhost. In a Docker context, localhost means the container itself, so your Vue app is trying to connect to itself.
Use this instead
module.exports = {
HOST: "mysql",
USER: "user",
PASSWORD: "12345678",
DB: "testdb",
dialect: "mysql",
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
}
};

Can't connect to flask app inside a docker container from host [duplicate]

This question already has answers here:
Deploying a minimal flask app in docker - server connection issues
(8 answers)
Closed 1 year ago.
I’m trying to run a Flask application and mysql database by running docker-compose up on my computer. The flask is running on port 5000.
if __name__ == "__main__":
app.run(port=5000, debug=True)
The docker container is responding properly when I use docker exec command. But I can't get any response from the host by using the url: http://localhost:5000.
The curl -X GET <url> command is giving the following output:
curl: (56) Recv failure: Connection reset by peer
The docker ps command is giving the following output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bffa59c471f6 customer_transaction_app "/bin/sh -c 'python …" About an hour ago Up About an hour 0.0.0.0:5000->5000/tcp customer_transaction_app_1
ad60c2830ac0 mysql "docker-entrypoint.s…" About an hour ago Up About an hour 33060/tcp, 0.0.0.0:32001->3306/tcp customertransaction_db_host
Here is the Dockerfile:
FROM python:3.8
EXPOSE 5000
COPY requirements.txt /app/requirements.txt
WORKDIR /app
RUN pip install -r requirements.txt
COPY . /app CMD
python main.py
Here is the docker-compose.yml file:
version: "2"
services:
app:
build: ./
depends_on:
- db
ports:
- "5000:5000"
db:
container_name: customertransaction_db_host
image: mysql
restart: always
ports:
- "32001:3306"
volumes:
- customertransaction-db-vol:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: customertransaction_db
MYSQL_USER: user
MYSQL_PASSWORD: 123456
volumes:
customertransaction-db-vol: {}
Both the containers reside inside a docker network customer_transaction_default. The docker network inspect command creates the following output:
[
{
"Name": "customer_transaction_default",
"Id": "4b5b20f503af0026a2f1ef185436c9a8e3d9c2ece690e93ece0e6b12f7821edb",
"Created": "2021-06-20T17:52:15.603679073+05:30",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.24.0.0/16",
"Gateway": "172.24.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"ad60c2830ac0f7e270daf03334ea8a8170200e92c2bc43492c378bd1d89cd3ac": {
"Name": "customertransaction_db_host",
"EndpointID": "de4597a1f58d711640f71a6169111f9842c7c5d74320825657a2518d07f36504",
"MacAddress": "02:42:ac:18:00:02",
"IPv4Address": "172.24.0.2/16",
"IPv6Address": ""
},
"bffa59c471f6762bb802fcee37db356cf2c7a59f4f88192e3546dd10ad9dbb2d": {
"Name": "customer_transaction_app_1",
"EndpointID": "a3ded03e28343921d799c0efc334034028821c231e1469d4359cd387c7f43f70",
"MacAddress": "02:42:ac:18:00:03",
"IPv4Address": "172.24.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
Since you are trying to connect a server in your docker network, you should change the host in the connection string that you are using to connect Mysql to the name of the container that you are willing to connect.
For your case, you have to change localhost with "customertransaction_db_host".

exec: \"mysql\": executable file not found in $PATH": unknown

I've created a container based on the mysql:5.7 image. Then I set the password with this
docker run --name mysql -v $(pwd):/src -e MYSQL_ROOT_PASSWORD=password -d mysql:5.7
Then I deployed my modules using docker-compose up -d on my docker-compose.yml file. Apparently, it raised an
exec: \"mysql\": executable file not found in $PATH": unknown
error and my 2 other modules also are having errors that keeps on restarting and point to mysql. I can import Python files in Django shell as well as mysql -u root -p but I cannot use the imports when it can't connect to the database.
Things I did based on my research:
I've set my Windows 10 environment variables to point at
C:\Program Files\MySQL\MySQL Server 8.0\bin where mysql.exe resides. It still didn't work.
mysql-init.txt (REF: https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html): This runs the mysql prompt successfully.
grant all privileges on *.* to root#localhost;
ALTER USER 'root'#'localhost' IDENTIFIED BY 'password';
docker-compose.yml
version: '2'
services:
# Mysql
mysql:
image: mysql:5.7
restart: always
hostname: mysql
container_name: mysql
environment:
- MYSQL_USER=root
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DB=bitpal
ports:
- "3306:3306"
# Redis
redis:
image: redis:latest
restart: always
hostname: redis
container_name: redis
ports:
- "6379:6379"
# Django web server
bitpal:
image: python:3.5
restart: always
hostname: bitpal
container_name: bitpal
working_dir: /bitpal
command: ./bin/start_dev.sh
volumes:
- ./bitpal:/bitpal
- ./etc/config:/etc/config
- ./log:/log
ports:
- "80:80"
links:
- mysql
- redis
depends_on:
- mysql
environment:
# Database
- DB_NAME=bitpal
- DB_USER=root
- DB_PASSWORD=password
- DB_HOST=mysql
- DB_PORT=3306
# Celery worker
worker:
image: python:3.5
restart: always
container_name: worker
command: bash -c "./bin/install.sh && ./bin/celery_worker.sh"
working_dir: /bitpal
volumes:
- ./bitpal:/bitpal
- ./etc/config:/etc/config
- ./log:/log
links:
- mysql
- redis
depends_on:
- redis
# Bitshares websocket listener
websocket_listener:
image: python:3.5
restart: always
container_name: websocket_listener
command: bash -c "./bin/install.sh && ./bin/websocket_listener.sh"
working_dir: /bitpal
volumes:
- ./bitpal:/bitpal
- ./etc/config:/etc/config
- ./log:/log
links:
- mysql
- redis
depends_on:
- redis
# Nginx
nginx:
image: nginx:1.12.1
container_name: nginx
ports:
- "8000:80"
volumes:
- ./bitpal:/home/bitpal/bitpal/bitpal
- ./nginx:/etc/nginx/conf.d
depends_on:
- bitpal
Dockerfile
FROM python:3.5
RUN mkdir -p /bitpal
WORKDIR /bitpal
EXPOSE 80
ADD requirement.txt /bitpal/
RUN python3.5 -m pip install -r /bitpal/requirement.txt
settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'bitpal',
'USER': 'root',
'PASSWORD': 'password',
'HOST': SECRETS['db']['default']['hostname'],
'PORT': '3306',
'OPTIONS': {'autocommit': SECRETS['db']['default']['commit']}
}
}
docker version
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:06:28 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.04.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.4
Git commit: 3d479c0
Built: Tue Apr 10 18:23:35 2018
OS/Arch: linux/amd64
Experimental: false
docker info
Containers: 6
Running: 3
Paused: 0
Stopped: 3
Images: 6
Server Version: 18.04.0-ce
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 46
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.93-boot2docker
Operating System: Boot2Docker 18.04.0-ce (TCL 8.2.1); HEAD : b8a34c0 - Wed Apr 11 17:00:55 UTC 2018
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 995.6MiB
Name: default
ID: I7DZ:5SQN:EOBV:PJOE:YHNK:RSXK:F6EH:4J7P:LSTI:CR2M:E2MV:VI27
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
provider=virtualbox
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
docker inspect mysql:5.7
[
{
"Id": "sha256:0d16d0a97dd13a8ca0c0e205ce1f31f64d9d32048379eb322749442bff35f144",
"RepoTags": [
"mysql:5.7"
],
"RepoDigests": [
"mysql#sha256:f030e84582d939d313fe2ef469b5c65ffd0f7dff3b4b98e6ec9ae2dccd83dcdf"
],
"Parent": "",
"Comment": "",
"Created": "2018-05-04T23:41:21.907294662Z",
"Container": "7fed895363c6e67ba9d52eaea107a1267d63e2d5ad46c567926d6897c7175624",
"ContainerConfig": {
"Hostname": "7fed895363c6",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3306/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.7",
"MYSQL_MAJOR=5.7",
"MYSQL_VERSION=5.7.22-1debian9"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"mysqld\"]"
],
"ArgsEscaped": true,
"Image": "sha256:71f4997ae44aead33eefe93100990253bca456f7b63dc5aad5baa936e7c14c46",
"Volumes": {
"/var/lib/mysql": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": [],
"Labels": {}
},
"DockerVersion": "17.06.2-ce",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3306/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.7",
"MYSQL_MAJOR=5.7",
"MYSQL_VERSION=5.7.22-1debian9"
],
"Cmd": [
"mysqld"
],
"ArgsEscaped": true,
"Image": "sha256:71f4997ae44aead33eefe93100990253bca456f7b63dc5aad5baa936e7c14c46",
"Volumes": {
"/var/lib/mysql": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": [],
"Labels": null
},
"Architecture": "amd64",
"Os": "linux",
"Size": 371961246,
"VirtualSize": 371961246,
"GraphDriver": {
"Data": null,
"Name": "aufs"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:d626a8ad97a1f9c1f2c4db3814751ada64f60aed927764a3f994fcd88363b659",
"sha256:0fea3c8895d3871f5c577987f09735ae0889811efbad0dfde4d57851a4d40c00",
"sha256:ed9fd767a1ff316e1a5896e150cede3ba2bcfe406d2135a6bc6306295cc479af",
"sha256:f9dfc87a2e756c25245847a95ced53a6c065405b417d7635a28aa88235b30786",
"sha256:5081cf9eb26642b5373aaa6eea7e16b6caefc3a495cf8fa0f296df48d8651f2f",
"sha256:0404d129c384e4f45e5ae6a8d89c388a323bc0dda82ea45c6e4d0a442ea1e4b0",
"sha256:98bb41f25d3307bc5c124529cfde7c3c27a0d612d918e91a36fc1e852e2e629c",
"sha256:c11f67aad663de23cb77fbbbc6f7bee656e95e72cc820733aed6430a618738ab",
"sha256:d2f1dc45f8bf45758eee7bc59fe94e9f251c415ef8d08540529d1a004772ee9e",
"sha256:01df4e5c105921d20d800c1250c66009d472eb5628817bfa2c9523df5c53e03c",
"sha256:4f840ea0733fe23b9fda79ff521a2e6e8112a615df5db064570502af19c08511"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]
Ok, I just got it resolved. Apparently, I forgot to create the DB and migrate the new changes. Here's how I did it.
Removed nginx module. My worker (celery) and websocket_listener modules are okay to keep on restarting. docker rm -f nginx
Ran in detached mode. docker-compose up -d mysql redis
Used bash under mysql container. docker exec -ti mysql bash
Entered credentials (I have initially set them in mysql-init.txt, REF: https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html) mysql -u root -p
Created DB. CREATE DATABASE bitpal;
Imported a certain .sql file that was missing in my modules.
Ran bitpal in detached mode. docker-compose up -d bitpal
Used bash under bitpal container. docker exec -ti bitpal bash
Migrations. python manage.py migrate
Used bash under mysql container. docker exec -ti mysql bash
Lastly, ran the sql under bitpal container. mysql -u root -p bitpal < <.sql file>
And it worked.
Here is the best option for the above issue. I did a lot of search for the same issue:
sudo apt-get install --reinstall mariadb-server
sudo apt-get install --reinstall php-mysql
service mysql status
service mysql start