Docker Postgres container is not starting for Rails Application - ruby

I am facing an issue on docker container. When I execute the docker-compose up to start the application the Postgres container is not starting.
Error which I get after docker-compose up
/usr/local/bundle/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize': could not translate host name "db" to address: Name or service not known (PG::ConnectionBad)
Now it is frequently happing. I tried with few steps as add ports for db container i.e 5432:5432. I used to start-stop the specific db container so that the connection should get re-established but it is not working.
Application details:
Rails Version: 4.2.0 Ruby version: 2.2.0
docker-compose.yml
version: '3.7'
services:
selenium:
image: selenium/standalone-chrome-debug:3.141.59-krypton
ports: ['4444:4444', '5900:5900']
logging:
driver: none
redis:
image: redis:3.0.0
elastic:
image: elasticsearch:1.5.2
db:
image: postgres:9.3.10
volumes:
- ./tmp/db:/var/lib/postgresql/data
- .:/home
XYZ:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
stdin_open: true
tty: true
volumes:
- XYZ-sync:/home:nocopy
ports:
- "3000:3000"
depends_on:
- db
- redis
- elastic
- selenium
environment:
- REDIS_URL=redis://redis:6379/0
- ELASTICSEARCH_URL=elastic://elastic:9200/0
- SELENIUM_HOST=selenium
- SELENIUM_PORT=4444
- TEST_APP_HOST=XYZ
- TEST_PORT=3000
db log
db_1 | LOG: database system was shut down at 2019-09-10 07:37:08 UTC
db_1 | LOG: MultiXact member wraparound protections are now enabled
db_1 | LOG: database system is ready to accept connections
db_1 | LOG: autovacuum launcher started
db_1 | LOG: received smart shutdown request
db_1 | LOG: autovacuum launcher shutting down
db_1 | LOG: shutting down
db_1 | LOG: database system is shut down
db_1 | LOG: database system was shut down at 2019-09-10 07:37:50 UTC
db_1 | LOG: MultiXact member wraparound protections are now enabled
db_1 | LOG: database system is ready to accept connections
db_1 | LOG: autovacuum launcher started
db_1 | LOG: database system was interrupted; last known up at 2019-09-10 07:38:31 UTC
db_1 | LOG: received smart shutdown request
db_1 | LOG: database system was interrupted; last known up at 2019-09-10 07:38:31 UTC
db_1 | LOG: database system was not properly shut down; automatic recovery in progress
db_1 | LOG: record with zero length at 0/1D8F0120
db_1 | LOG: redo is not required
db_1 | LOG: MultiXact member wraparound protections are now enabled
db_1 | LOG: autovacuum launcher started
db_1 | LOG: database system is ready to accept connections
db_1 | LOG: stats_timestamp 2019-09-10 08:02:39.288642+00 is later than collector's time 2019-09-10 08:02:39.189551+00 for database 0
db_1 | LOG: database system was interrupted; last known up at 2019-09-10 08:18:02 UTC
db_1 | FATAL: the database system is starting up
docker-compose ps output
xyz_db_1 /docker-entrypoint.sh postgres Up 5432/tcp
xyz_elastic_1 /docker-entrypoint.sh elas ... Up 9200/tcp, 9300/tcp
xyz_xyz_1 bash -c rm -f tmp/pids/ser ... Exit 1
xyz_redis_1 /entrypoint.sh redis-server Up 6379/tcp
xyz_selenium_1 /opt/bin/entry_point.sh Up 0.0.0.0:4444->4444/tcp, 0.0.0.0:5900->5900/tcp
database.yml
default: &default
adapter: postgresql
encoding: unicode
pool: 5
username: postgres
password:
host: db
development:
<<: *default
database: XYZ_development
test:
<<: *default
database: XYZ_test
development_migrate:
adapter: mysql2
encoding: utf8
database: xyz_ee
username: root
password:
host: localhost
pool: 5
Any help will be appreciated.

I resolved my issue with the help of #jayDosrsey suggestion.
The DB container get started before the main web container and hence it always gets failed to start the container and I again need to restart the web container.
Resolved this issue by adding the health check condition while starting the rails server.
XYZ:
build: .
command: bash -c "while !</dev/tcp/db/5432; do sleep 1; done; rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
...
Now I am able to start the container in sequence.

Related

how can docker-compose run comands as no-root user

how can docker-compose run comands as no-root user? My docker-compose.yml just show below:
version: "3"
services:
sonarqube-h:
image: sonarqube:community
user: "${UID}:${GID}"
depends_on:
- db
environment:
SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
SONAR_JDBC_USERNAME: sonar
SONAR_JDBC_PASSWORD: sonar
volumes:
- /home/win/docker-app/sonarqube/docker-compose-sonardata/data:/opt/sonarqube/data
- /home/win/docker-app/sonarqube/docker-compose-sonardata/extensions:/opt/sonarqube/extensions
- /home/win/docker-app/sonarqube/docker-compose-sonardata/logs:/opt/sonarqube/logs
- /home/win/docker-app/sonarqube/docker-compose-sonardata/conf:/opt/sonarqube/conf
ports:
- "9001:9000"
networks:
sonarqube-net:
ipv4_address: 172.19.0.8
db:
image: postgres:12
environment:
POSTGRES_USER: sonar
POSTGRES_PASSWORD: sonar
volumes:
- /home/win/docker-app/sonarqube/docker-compose-sonardata/postgresql:/var/lib/postgresql
- /home/win/docker-app/sonarqube/docker-compose-sonardata/postgresql/data:/var/lib/postgresql/data
networks:
sonarqube-net:
ipv4_address: 172.19.0.7
networks:
sonarqube-net:
driver: bridge
ipam:
config:
- subnet: 172.19.0.0/16
when I use env UID=1000 GID=1000 docker-compose up to build, It turns out to be logs belows, due to the es was run as root user:
sonarqube-h_1 | 2022.03.03 15:33:37 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:39789]
sonarqube-h_1 | 2022.03.03 15:33:38 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch
sonarqube-h_1 | could not find java in ES_JAVA_HOME at /usr/lib/jvm/java-11-openjdk/bin/java
sonarqube-h_1 | 2022.03.03 15:33:38 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
sonarqube-h_1 | 2022.03.03 15:33:38 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1
sonarqube-h_1 | 2022.03.03 15:33:38 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped
sonarqube-h_1 | 2022.03.03 15:33:38 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
sonarqube_sonarqube-h_1 exited with code 0

Postgres 13 service will not start after installing Postgres 14

I have been using Postgresql 13 on a local server on my Windows 10 computer for over a year successfully now. I decided to upgrade to 14 yesterday.
I installed 14 on a different port. I went to go and upgrade as per this command: pg_upgrade -d "c:\Program Files\PostgreSQL\13\data" -D "c:\Program Files\PostgreSQL\14\data" -b "c:\Program Files\PostgreSQL\13\bin" -B "c:\Program Files\PostgreSQL\14\bin" -U Postgres, but it said it cannot connect to the 13 server. I restarted the computer, and still the 13's Service will not start.
When I type pg_ctl -D "C:\Program Files\PostgreSQL\13\data" start at the cmd line, the below is what shows in my log:
2022-02-15 08:53:45.908 +04 [92100] LOG: starting PostgreSQL 13.3, compiled by Visual C++ build 1914, 64-bit
2022-02-15 08:53:45.909 +04 [92100] LOG: listening on IPv6 address "::", port 5432
2022-02-15 08:53:45.910 +04 [92100] LOG: listening on IPv4 address "0.0.0.0", port 5432
2022-02-15 08:53:45.954 +04 [92672] LOG: database system was shut down at 2022-02-14 14:08:25 +04
2022-02-15 08:53:45.955 +04 [92672] LOG: invalid record length at 24/80B400C8: wanted 24, got 0
2022-02-15 08:53:45.955 +04 [92672] LOG: invalid primary checkpoint record
2022-02-15 08:53:45.955 +04 [92672] PANIC: could not locate a valid checkpoint record
2022-02-15 08:53:46.057 +04 [92100] LOG: startup process (PID 92672) was terminated by exception 0xC0000409
2022-02-15 08:53:46.057 +04 [92100] HINT: See C include file "ntstatus.h" for a description of the hexadecimal value.
2022-02-15 08:53:46.057 +04 [92100] LOG: aborting startup due to startup process failure
2022-02-15 08:53:46.059 +04 [92100] LOG: database system is shut down
What should I do to fix this?
What I have already done is:
PostgreSQL.conf - made sure listen_addresses = '*' was uncommented
made sure Modify was valid for all users of the computer on the Postgres Programs folder
I checked that the Postgres user had full rights to the folder, but there was no user found in my windows.
I added to the pg_hba file: #host all all 0.0.0.0/0 scram-sha-256
oh, and in case it's not apparent, I don't know much about Postgres. I can use it for what I need and that's about it.
As JJanes suggested. I did a backup and then restored in the new server of Postgres 14. It solved the problem. Thank you, JJanes.

Spring Boot Application does not start after Deployment (Docker Compose)

Hey folks I have a problem: I need to deploy a Spring Boot App with docker compose but after docker has deployed the contents of the Folder Spring Boot does not start to boot.
The thing is this has worked before but now it won't so I think it has something to do with my docker configuration. I can't really read something out of the log, please help me.
Here are the outputs of docker-compose logs:
root#h2916245:/home/carta# docker-compose up
Creating network "carta_default" with the default driver
Creating carta_cartadb_1 ... done
Creating carta_frontend_1 ... done
Attaching to carta_cartadb_1, carta_frontend_1
cartadb_1 | ********************************************************************************
cartadb_1 | WARNING: POSTGRES_HOST_AUTH_METHOD has been set to "trust". This will allow
cartadb_1 | anyone with access to the Postgres port to access your database without
cartadb_1 | a password, even if POSTGRES_PASSWORD is set. See PostgreSQL
cartadb_1 | documentation about "trust":
cartadb_1 | https://www.postgresql.org/docs/current/auth-trust.html
cartadb_1 | In Docker's default configuration, this is effectively any other
cartadb_1 | container on the same system.
cartadb_1 |
cartadb_1 | It is not recommended to use POSTGRES_HOST_AUTH_METHOD=trust. Replace
cartadb_1 | it with "-e POSTGRES_PASSWORD=password" instead to set a password in
cartadb_1 | "docker run".
cartadb_1 | ********************************************************************************
cartadb_1 | The files belonging to this database system will be owned by user "postgres".
cartadb_1 | This user must also own the server process.
cartadb_1 |
cartadb_1 | The database cluster will be initialized with locale "en_US.utf8".
cartadb_1 | The default database encoding has accordingly been set to "UTF8".
cartadb_1 | The default text search configuration will be set to "english".
cartadb_1 |
cartadb_1 | Data page checksums are disabled.
cartadb_1 |
cartadb_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
cartadb_1 | creating subdirectories ... ok
cartadb_1 | selecting dynamic shared memory implementation ... posix
cartadb_1 | selecting default max_connections ... 100
cartadb_1 | selecting default shared_buffers ... 128MB
cartadb_1 | selecting default time zone ... Etc/UTC
cartadb_1 | creating configuration files ... ok
cartadb_1 | running bootstrap script ... ok
frontend_1 | NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
cartadb_1 | performing post-bootstrap initialization ... ok
cartadb_1 | syncing data to disk ... initdb: warning: enabling "trust" authentication for local connections
cartadb_1 | You can change this by editing pg_hba.conf or using the option -A, or
cartadb_1 | --auth-local and --auth-host, the next time you run initdb.
cartadb_1 | ok
cartadb_1 |
cartadb_1 |
cartadb_1 | Success. You can now start the database server using:
cartadb_1 |
cartadb_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
cartadb_1 |
cartadb_1 | waiting for server to start....2021-10-06 18:18:23.390 UTC [50] LOG: starting PostgreSQL 14.0 (Debian 14.0-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
cartadb_1 | 2021-10-06 18:18:23.390 UTC [50] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
cartadb_1 | 2021-10-06 18:18:23.394 UTC [51] LOG: database system was shut down at 2021-10-06 18:18:23 UTC
cartadb_1 | 2021-10-06 18:18:23.401 UTC [50] LOG: database system is ready to accept connections
cartadb_1 | done
cartadb_1 | server started
cartadb_1 | CREATE DATABASE
cartadb_1 |
cartadb_1 |
cartadb_1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
cartadb_1 |
cartadb_1 | 2021-10-06 18:18:23.735 UTC [50] LOG: received fast shutdown request
cartadb_1 | 2021-10-06 18:18:23.735 UTC [50] LOG: aborting any active transactions
cartadb_1 | waiting for server to shut down....2021-10-06 18:18:23.740 UTC [50] LOG: background worker "logical replication launcher" (PID 57) exited with exit code 1
cartadb_1 | 2021-10-06 18:18:23.740 UTC [52] LOG: shutting down
cartadb_1 | 2021-10-06 18:18:23.756 UTC [50] LOG: database system is shut down
cartadb_1 | done
cartadb_1 | server stopped
cartadb_1 |
cartadb_1 | PostgreSQL init process complete; ready for start up.
cartadb_1 |
frontend_1 | 06-Oct-2021 20:18:23.846 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/10.0.11
cartadb_1 | 2021-10-06 18:18:23.886 UTC [1] LOG: starting PostgreSQL 14.0 (Debian 14.0-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
cartadb_1 | 2021-10-06 18:18:23.887 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
cartadb_1 | 2021-10-06 18:18:23.888 UTC [1] LOG: listening on IPv6 address "::", port 5432
cartadb_1 | 2021-10-06 18:18:23.888 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
cartadb_1 | 2021-10-06 18:18:23.891 UTC [64] LOG: database system was shut down at 2021-10-06 18:18:23 UTC
frontend_1 | 06-Oct-2021 20:18:23.890 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Sep 6 2021 16:22:12 UTC
frontend_1 | 06-Oct-2021 20:18:23.891 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 10.0.11.0
frontend_1 | 06-Oct-2021 20:18:23.891 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
frontend_1 | 06-Oct-2021 20:18:23.891 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 5.4.0
frontend_1 | 06-Oct-2021 20:18:23.891 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
frontend_1 | 06-Oct-2021 20:18:23.892 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/local/openjdk-11
frontend_1 | 06-Oct-2021 20:18:23.892 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 11.0.12+7
frontend_1 | 06-Oct-2021 20:18:23.892 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
frontend_1 | 06-Oct-2021 20:18:23.893 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/tomcat
frontend_1 | 06-Oct-2021 20:18:23.893 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/tomcat
cartadb_1 | 2021-10-06 18:18:23.899 UTC [1] LOG: database system is ready to accept connections
frontend_1 | 06-Oct-2021 20:18:23.915 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
frontend_1 | 06-Oct-2021 20:18:23.921 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
frontend_1 | 06-Oct-2021 20:18:23.921 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
frontend_1 | 06-Oct-2021 20:18:23.922 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
frontend_1 | 06-Oct-2021 20:18:23.922 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
frontend_1 | 06-Oct-2021 20:18:23.922 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
frontend_1 | 06-Oct-2021 20:18:23.923 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
frontend_1 | 06-Oct-2021 20:18:23.923 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
frontend_1 | 06-Oct-2021 20:18:23.923 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
frontend_1 | 06-Oct-2021 20:18:23.924 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
frontend_1 | 06-Oct-2021 20:18:23.930 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
frontend_1 | 06-Oct-2021 20:18:23.930 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
frontend_1 | 06-Oct-2021 20:18:23.930 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
frontend_1 | 06-Oct-2021 20:18:23.931 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
frontend_1 | 06-Oct-2021 20:18:23.942 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.31] using APR version [1.7.0].
frontend_1 | 06-Oct-2021 20:18:23.943 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
frontend_1 | 06-Oct-2021 20:18:23.956 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1k 25 Mar 2021]
frontend_1 | 06-Oct-2021 20:18:24.736 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
frontend_1 | 06-Oct-2021 20:18:24.812 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [1629] milliseconds
frontend_1 | 06-Oct-2021 20:18:24.949 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
frontend_1 | 06-Oct-2021 20:18:24.950 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.0.11]
frontend_1 | 06-Oct-2021 20:18:24.963 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/carta-1.3.war]
frontend_1 | 06-Oct-2021 20:18:25.555 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/carta-1.3.war] has finished in [591] ms
frontend_1 | 06-Oct-2021 20:18:25.560 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
frontend_1 | 06-Oct-2021 20:18:25.587 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [765] milliseconds
Here is my docker-compose file:
version: '3'
services:
cartadb:
image: postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=carta
- POSTGRES_HOST_AUTH_METHOD=trust
ports:
- "5432:5432"
frontend:
depends_on:
- cartadb
image: tomcat
ports:
- "80:8080"
volumes:
- ./carta-1.3.war:/usr/local/tomcat/webapps/carta-1.3.war
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=carta
- POSTGRES_HOST_AUTH_METHOD=trust
and here is my Main Class:
#SpringBootApplication
public class CartaApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(CartaApplication.class, args);
}
}

Docker - mysql configured with empty password for the root user

I am new to docker and try to run a mysql image using below command on a windows server.
docker run -e MYSQL_ROOT_PASSWORD=sEe#21 -e MYSQL_DATABASE=emp_db -p 3306:3306 --name mysql_emp mysql
It successfully downloaded and configured. I am getting a log in the CMD which says
root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
I have already given the root password which I set to use by the application and hence I get an error saying that cannot connect to DB from the spring boot service. MySQL full log is as follows
2021-02-10 14:25:43+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-02-10 14:25:43+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-02-10 14:25:43+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-02-10 14:25:43+00:00 [Note] [Entrypoint]: Initializing database files
2021-02-10T14:25:43.801929Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.23) initializing of server in progress as process 43
2021-02-10T14:25:43.808218Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-02-10T14:25:44.547274Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-02-10T14:25:46.632843Z 6 [Warning] [MY-010453] [Server] root#localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2021-02-10 14:25:51+00:00 [Note] [Entrypoint]: Database files initialized
2021-02-10 14:25:51+00:00 [Note] [Entrypoint]: Starting temporary server
2021-02-10T14:25:51.770335Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.23) starting as process 88
2021-02-10T14:25:51.804446Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-02-10T14:25:52.039318Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-02-10T14:25:52.169969Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
2021-02-10T14:25:52.299951Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-02-10T14:25:52.300259Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-02-10T14:25:52.304466Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2021-02-10T14:25:52.327240Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server - GPL.
2021-02-10 14:25:52+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2021-02-10 14:25:58+00:00 [Note] [Entrypoint]: Creating database emp_db
2021-02-10 14:25:58+00:00 [Note] [Entrypoint]: Stopping temporary server
2021-02-10T14:25:58.448858Z 11 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.23).
2021-02-10T14:26:00.212816Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.23) MySQL Community Server - GPL.
2021-02-10 14:26:00+00:00 [Note] [Entrypoint]: Temporary server stopped
2021-02-10 14:26:00+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
2021-02-10T14:26:00.738118Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.23) starting as process 1
2021-02-10T14:26:00.763121Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-02-10T14:26:00.999006Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-02-10T14:26:01.135971Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2021-02-10T14:26:01.269210Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-02-10T14:26:01.269444Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-02-10T14:26:01.275037Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2021-02-10T14:26:01.297388Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
Would like to understand what is wrong I am doing ? any parameter is missing in the docker run command ?
It is just an example of misleading printing:
That is just a warning printed by during database file initialization (mysqld --initialize-insecure). The root user with password is created later while the database is listening only on the unix socket.
From https://github.com/docker-library/mysql/issues/307#issuecomment-313784886
What happens if you structure your run command as it is on the MySQL Docker hub page:
docker run --name mysql_emp -e MYSQL_ROOT_PASSWORD=sEe#21 -e MYSQL_DATABASE=emp_db -p 3306:3306 -d mysql:latest
If that doesn't work you could try running from a dockerfile, similar to this question: MYSQL docker file

Docker Percona exits with error 3 in macOS

Using Docker Toolbox in macOS 10.11. Trying to start Percona 5.7 container via docker-compose:
percona:
image: percona:5.7
user: "1000:50"
restart: "no"
volumes:
- ./db:/var/lib/mysql:rw
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: qwerty
But when run:
docker-compose up
it shows me this log:
percona_1 | Initializing database
percona_1 | 2018-02-27T18:21:40.471171Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
percona_1 | 2018-02-27T18:21:40.471336Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
percona_1 | 2018-02-27T18:21:40.509126Z 0 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
percona_1 | 2018-02-27T18:21:40.511757Z 0 [Warning] One can only use the --user switch if running as root
percona_1 |
percona_1 | 2018-02-27T18:21:42.900823Z 0 [ERROR] InnoDB: Operating system error number 22 in a file operation.
percona_1 | 2018-02-27T18:21:42.901071Z 0 [ERROR] InnoDB: Error number 22 means 'Invalid argument'
percona_1 | 2018-02-27T18:21:42.901164Z 0 [ERROR] InnoDB: File ./ib_logfile101: 'aio write' returned OS error 122. Cannot continue operation
percona_1 | 2018-02-27T18:21:42.901187Z 0 [ERROR] InnoDB: Cannot continue operation.
docker_percona_1 exited with code 3
Can you help me understand the problem?
It means the filesystem your using doesn't support aio. You can tell this to innodb by adding the following line to my.cnf:
innodb_use_native_aio=0
also remove innodb_flush_method = O_DIRECT if enabled in my.cnf

Resources