I am trying to create my first php with mysql application using docker compose. For so I have my own application and create 1 file as Dockerfile and docker-compose.yml file to compose it by using command ‘docker-compose up’
My Dockerfile code is
FROM php:7.3.3-apache
RUN apt-get update && apt-get upgrade -y
RUN docker-php-ext-install mysqli
Expose 80
Ans my docker-compose.yml file is
version: '3.3'
services:
db:
container_name: mysql8
image: mysql:5.7
command: --default-authentication-plugin=mysql_native_password
volumes:
- ./src/Database:/docker-entrypoint-initdb.d
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: new_shopcart
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
MYSQL_HOST: localhost
ports:
- "8011:3306"
phpmyadmin:
container_name: shopcart_phpmyadmin
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- "8012:80"
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: root
web:
build:
context: ./src
dockerfile: Dockerfile
container_name: php73
depends_on:
- db
volumes:
- ./src:/var/www/html/ #src is my php application code directory
ports:
- "8013:80"
Error is
Warning: mysqli_connect(): (HY000/2002): No such file or directory in /var/www/html/includes/connection.php on line 3
Warning: mysqli_connect(): (HY000/2002): No such file or directory in /var/www/html/functions/functions.php on line 2
NOTE : phpmyadmin is running. i can login and see that database is created and successfully create all tables in database. also create username and password as well as others created.
if you want to see logs then here it is
Building web
Step 1/4 : FROM php:7.3.3-apache
---> 406c73effb13
Step 2/4 : RUN apt-get update && apt-get upgrade -y
---> Using cache
---> 17f8cc57a8bd
Step 3/4 : RUN docker-php-ext-install mysqli
---> Using cache
---> 5210c1924f9e
Step 4/4 : Expose 80
---> Using cache
---> f628785adc53
Successfully built f628785adc53
Successfully tagged web_dev_web:latest
Creating mysql8 ... done
Creating php73 ... done
Creating shopcart_phpmyadmin ... done
Attaching to mysql8, php73, shopcart_phpmyadmin
mysql8 | 2020-03-09 21:09:57+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.29-1debian10 started.
mysql8 | 2020-03-09 21:09:57+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mysql8 | 2020-03-09 21:09:58+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.29-1debian10 started.
mysql8 | 2020-03-09 21:09:58+00:00 [Note] [Entrypoint]: Initializing database files
mysql8 | 2020-03-09T21:09:58.296997Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql8 | 2020-03-09T21:09:59.526362Z 0 [Warning] InnoDB: New log files created, LSN=45790
mysql8 | 2020-03-09T21:09:59.772683Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
mysql8 | 2020-03-09T21:09:59.847861Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 5604cccc-624a-11ea-bdf8-0242ac130002.
mysql8 | 2020-03-09T21:09:59.851785Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
php73 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message
php73 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message
php73 | [Mon Mar 09 21:10:00.921144 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.3.3 configured -- resuming normal operations
php73 | [Mon Mar 09 21:10:00.935781 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
shopcart_phpmyadmin | phpMyAdmin not found in /var/www/html - copying now...
shopcart_phpmyadmin | Complete! phpMyAdmin has been successfully copied to /var/www/html
shopcart_phpmyadmin | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.4. Set the 'ServerName' directive globally to suppress this message
shopcart_phpmyadmin | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.4. Set the 'ServerName' directive globally to suppress this message
shopcart_phpmyadmin | [Mon Mar 09 21:10:02.406367 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.1 configured -- resuming normal operations
shopcart_phpmyadmin | [Mon Mar 09 21:10:02.419347 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
mysql8 | 2020-03-09T21:10:02.561109Z 0 [Warning] CA certificate ca.pem is self signed.
mysql8 | 2020-03-09T21:10:02.873795Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
mysql8 | 2020-03-09 21:10:06+00:00 [Note] [Entrypoint]: Database files initialized
mysql8 | 2020-03-09 21:10:06+00:00 [Note] [Entrypoint]: Starting temporary server
mysql8 | 2020-03-09 21:10:06+00:00 [Note] [Entrypoint]: Waiting for server startup
mysql8 | 2020-03-09T21:10:06.198419Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql8 | 2020-03-09T21:10:06.199505Z 0 [Note] mysqld (mysqld 5.7.29) starting as process 76 ...
mysql8 | 2020-03-09T21:10:06.203183Z 0 [Note] InnoDB: PUNCH HOLE support available
mysql8 | 2020-03-09T21:10:06.203434Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mysql8 | 2020-03-09T21:10:06.203630Z 0 [Note] InnoDB: Uses event mutexes
mysql8 | 2020-03-09T21:10:06.203852Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
mysql8 | 2020-03-09T21:10:06.204055Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
mysql8 | 2020-03-09T21:10:06.204241Z 0 [Note] InnoDB: Using Linux native AIO
mysql8 | 2020-03-09T21:10:06.204611Z 0 [Note] InnoDB: Number of pools: 1
mysql8 | 2020-03-09T21:10:06.204918Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysql8 | 2020-03-09T21:10:06.206181Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
mysql8 | 2020-03-09T21:10:06.222906Z 0 [Note] InnoDB: Completed initialization of buffer pool
mysql8 | 2020-03-09T21:10:06.227873Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
mysql8 | 2020-03-09T21:10:06.239213Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
mysql8 | 2020-03-09T21:10:06.555450Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
mysql8 | 2020-03-09T21:10:06.555582Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
mysql8 | 2020-03-09T21:10:06.841921Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
mysql8 | 2020-03-09T21:10:06.842719Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
mysql8 | 2020-03-09T21:10:06.842729Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
mysql8 | 2020-03-09T21:10:06.842959Z 0 [Note] InnoDB: Waiting for purge to start
mysql8 | 2020-03-09T21:10:06.893384Z 0 [Note] InnoDB: 5.7.29 started; log sequence number 2630176
mysql8 | 2020-03-09T21:10:06.894283Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysql8 | 2020-03-09T21:10:06.897893Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mysql8 | 2020-03-09T21:10:06.899652Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200309 21:10:06
mysql8 | 2020-03-09T21:10:06.904401Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
mysql8 | 2020-03-09T21:10:06.909439Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
mysql8 | 2020-03-09T21:10:06.910305Z 0 [Warning] CA certificate ca.pem is self signed.
mysql8 | 2020-03-09T21:10:06.910622Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
mysql8 | 2020-03-09T21:10:07.081237Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
mysql8 | 2020-03-09T21:10:07.095040Z 0 [Note] Event Scheduler: Loaded 0 events
mysql8 | 2020-03-09T21:10:07.098135Z 0 [Note] mysqld: ready for connections.
mysql8 | Version: '5.7.29' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server (GPL)
mysql8 | 2020-03-09 21:10:08+00:00 [Note] [Entrypoint]: Temporary server started.
mysql8 | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
mysql8 | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
mysql8 | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
mysql8 | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
mysql8 | 2020-03-09 21:10:10+00:00 [Note] [Entrypoint]: Creating database new_shopcart
mysql8 | 2020-03-09 21:10:10+00:00 [Note] [Entrypoint]: Creating user wordpress
mysql8 | 2020-03-09 21:10:10+00:00 [Note] [Entrypoint]: Giving user wordpress access to schema new_shopcart
mysql8 |
mysql8 | 2020-03-09 21:10:10+00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/shopcart.sql
mysql8 |
mysql8 |
mysql8 | 2020-03-09 21:10:12+00:00 [Note] [Entrypoint]: Stopping temporary server
mysql8 | 2020-03-09T21:10:12.514003Z 0 [Note] Giving 0 client threads a chance to die gracefully
mysql8 | 2020-03-09T21:10:12.514396Z 0 [Note] Shutting down slave threads
mysql8 | 2020-03-09T21:10:12.514679Z 0 [Note] Forcefully disconnecting 0 remaining clients
mysql8 | 2020-03-09T21:10:12.514895Z 0 [Note] Event Scheduler: Purging the queue. 0 events
mysql8 | 2020-03-09T21:10:12.515118Z 0 [Note] Binlog end
mysql8 | 2020-03-09T21:10:12.515945Z 0 [Note] Shutting down plugin 'ngram'
mysql8 | 2020-03-09T21:10:12.517927Z 0 [Note] Shutting down plugin 'partition'
mysql8 | 2020-03-09T21:10:12.518323Z 0 [Note] Shutting down plugin 'BLACKHOLE'
mysql8 | 2020-03-09T21:10:12.518624Z 0 [Note] Shutting down plugin 'ARCHIVE'
mysql8 | 2020-03-09T21:10:12.518845Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
mysql8 | 2020-03-09T21:10:12.519059Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
mysql8 | 2020-03-09T21:10:12.519247Z 0 [Note] Shutting down plugin 'MyISAM'
mysql8 | 2020-03-09T21:10:12.519482Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
mysql8 | 2020-03-09T21:10:12.519690Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
mysql8 | 2020-03-09T21:10:12.519772Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
mysql8 | 2020-03-09T21:10:12.519810Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
mysql8 | 2020-03-09T21:10:12.519931Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
mysql8 | 2020-03-09T21:10:12.519970Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
mysql8 | 2020-03-09T21:10:12.520016Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
mysql8 | 2020-03-09T21:10:12.520051Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
mysql8 | 2020-03-09T21:10:12.520086Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
mysql8 | 2020-03-09T21:10:12.520121Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
mysql8 | 2020-03-09T21:10:12.520156Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
mysql8 | 2020-03-09T21:10:12.520191Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
mysql8 | 2020-03-09T21:10:12.520228Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
mysql8 | 2020-03-09T21:10:12.520263Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
mysql8 | 2020-03-09T21:10:12.520297Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
mysql8 | 2020-03-09T21:10:12.520366Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
mysql8 | 2020-03-09T21:10:12.520404Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
mysql8 | 2020-03-09T21:10:12.520475Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
mysql8 | 2020-03-09T21:10:12.520521Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
mysql8 | 2020-03-09T21:10:12.520578Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
mysql8 | 2020-03-09T21:10:12.520616Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
mysql8 | 2020-03-09T21:10:12.520770Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
mysql8 | 2020-03-09T21:10:12.520809Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
mysql8 | 2020-03-09T21:10:12.520845Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
mysql8 | 2020-03-09T21:10:12.520880Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
mysql8 | 2020-03-09T21:10:12.520915Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
mysql8 | 2020-03-09T21:10:12.520950Z 0 [Note] Shutting down plugin 'INNODB_CMP'
mysql8 | 2020-03-09T21:10:12.520985Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
mysql8 | 2020-03-09T21:10:12.521020Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
mysql8 | 2020-03-09T21:10:12.521057Z 0 [Note] Shutting down plugin 'INNODB_TRX'
mysql8 | 2020-03-09T21:10:12.521092Z 0 [Note] Shutting down plugin 'InnoDB'
mysql8 | 2020-03-09T21:10:12.522580Z 0 [Note] InnoDB: FTS optimize thread exiting.
mysql8 | 2020-03-09T21:10:12.522758Z 0 [Note] InnoDB: Starting shutdown...
mysql8 | 2020-03-09T21:10:12.623137Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
mysql8 | 2020-03-09T21:10:12.623367Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 200309 21:10:12
mysql8 | 2020-03-09T21:10:14.344285Z 0 [Note] InnoDB: Shutdown completed; log sequence number 13106282
mysql8 | 2020-03-09T21:10:14.346058Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
mysql8 | 2020-03-09T21:10:14.346359Z 0 [Note] Shutting down plugin 'MEMORY'
mysql8 | 2020-03-09T21:10:14.346580Z 0 [Note] Shutting down plugin 'CSV'
mysql8 | 2020-03-09T21:10:14.346768Z 0 [Note] Shutting down plugin 'sha256_password'
mysql8 | 2020-03-09T21:10:14.346952Z 0 [Note] Shutting down plugin 'mysql_native_password'
mysql8 | 2020-03-09T21:10:14.347271Z 0 [Note] Shutting down plugin 'binlog'
mysql8 | 2020-03-09T21:10:14.348520Z 0 [Note] mysqld: Shutdown complete
mysql8 |
mysql8 | 2020-03-09 21:10:14+00:00 [Note] [Entrypoint]: Temporary server stopped
mysql8 |
mysql8 | 2020-03-09 21:10:14+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
mysql8 |
mysql8 | 2020-03-09T21:10:14.700608Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql8 | 2020-03-09T21:10:14.701961Z 0 [Note] mysqld (mysqld 5.7.29) starting as process 1 ...
mysql8 | 2020-03-09T21:10:14.706026Z 0 [Note] InnoDB: PUNCH HOLE support available
mysql8 | 2020-03-09T21:10:14.706350Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mysql8 | 2020-03-09T21:10:14.706557Z 0 [Note] InnoDB: Uses event mutexes
mysql8 | 2020-03-09T21:10:14.706748Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
mysql8 | 2020-03-09T21:10:14.706939Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
mysql8 | 2020-03-09T21:10:14.707164Z 0 [Note] InnoDB: Using Linux native AIO
mysql8 | 2020-03-09T21:10:14.707640Z 0 [Note] InnoDB: Number of pools: 1
mysql8 | 2020-03-09T21:10:14.707941Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysql8 | 2020-03-09T21:10:14.709342Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
mysql8 | 2020-03-09T21:10:14.720781Z 0 [Note] InnoDB: Completed initialization of buffer pool
mysql8 | 2020-03-09T21:10:14.722794Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
mysql8 | 2020-03-09T21:10:14.753000Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
mysql8 | 2020-03-09T21:10:14.783192Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
mysql8 | 2020-03-09T21:10:14.783942Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
mysql8 | 2020-03-09T21:10:14.907493Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
mysql8 | 2020-03-09T21:10:14.908136Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
mysql8 | 2020-03-09T21:10:14.908142Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
mysql8 | 2020-03-09T21:10:14.908331Z 0 [Note] InnoDB: Waiting for purge to start
mysql8 | 2020-03-09T21:10:14.958502Z 0 [Note] InnoDB: 5.7.29 started; log sequence number 13106282
mysql8 | 2020-03-09T21:10:14.958769Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysql8 | 2020-03-09T21:10:14.962465Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mysql8 | 2020-03-09T21:10:14.963649Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200309 21:10:14
mysql8 | 2020-03-09T21:10:14.965183Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
mysql8 | 2020-03-09T21:10:14.965432Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
mysql8 | 2020-03-09T21:10:14.966208Z 0 [Warning] CA certificate ca.pem is self signed.
mysql8 | 2020-03-09T21:10:14.966964Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
mysql8 | 2020-03-09T21:10:14.970027Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
mysql8 | 2020-03-09T21:10:14.971853Z 0 [Note] IPv6 is available.
mysql8 | 2020-03-09T21:10:14.971941Z 0 [Note] - '::' resolves to '::';
mysql8 | 2020-03-09T21:10:14.972013Z 0 [Note] Server socket created on IP: '::'.
mysql8 | 2020-03-09T21:10:14.974528Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
mysql8 | 2020-03-09T21:10:14.984366Z 0 [Note] Event Scheduler: Loaded 0 events
mysql8 | 2020-03-09T21:10:14.985787Z 0 [Note] mysqld: ready for connections.
mysql8 | Version: '5.7.29' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)