I have a WordPress and MySQL container with a persistent volume. I have been trying to learn docker, and in the process have mistakenly deleted the old docker-compose.yml and all but the mysql volume. I have now recreated it to the compose file to the best of my ability, but whenever I boot the machine, it fails to connect to the MySQL server. Would anyone be able to point out where I'm going wrong.
I suspect I have an issue with the link between the two, but I'm not sure.
docker-compose.yml:
version: '2'
services:
wp.spm:
restart: always
image: wordpress:latest
ports:
- "8080:80"
environment:
WORDPRESS_DB_HOST: localhost:3306
WORDPRESS_DB_USER: spm
WORDPRESS_DB_PASSWORD: Ivietoo2Phah8xay
WORDPRESS_DB_NAME: spm
links:
- mysql.5.7
working_dir: /var/www/html
volumes:
- ./wp-content:/var/www/html/wp-content
mysql.5.7:
restart: always
image: mysql:5.7
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: root # TODO: Change this
MYSQL_USER: spm
MYSQL_PASS: Ivietoo2Phah8xay
MYSQL_DATABASE: spm
volumes:
- db_data:/var/lib/mysql
volumes:
db_data:
log:
$ docker-compose up
Pulling mysql.5.7 (mysql:5.7)...
5.7: Pulling from library/mysql
75a822cd7888: Pull complete
b8d5846e536a: Pull complete
b75e9152a170: Pull complete
832e6b030496: Pull complete
fe4a6c835905: Pull complete
c3f247e29ab1: Pull complete
21be3e562071: Pull complete
c7399d6bf033: Pull complete
ccdaeae6c735: Pull complete
713c7d65b0d3: Pull complete
86c18539deb2: Pull complete
Digest: sha256:9ef4478a3aa597f59b2266d5702f55f29acc468b5bf3518c3c90cbca4e243823
Status: Downloaded newer image for mysql:5.7
Pulling wp.spm (wordpress:latest)...
latest: Pulling from library/wordpress
75a822cd7888: Already exists
e4d8a4e038be: Pull complete
81d4d961577a: Pull complete
f0a3d7c702e3: Pull complete
a4b7d2c4c9cc: Pull complete
de3fbbff60a9: Pull complete
336c38203cc2: Pull complete
628c443fd26f: Pull complete
6b43451e2e60: Pull complete
a4dc6da381e6: Pull complete
771a9ee2bb6a: Pull complete
3862c25af8ee: Pull complete
a3bf90f1df74: Pull complete
4564f4870a3e: Pull complete
ec9c03f98075: Pull complete
5f4dfa2bfbb4: Pull complete
69feb6fb40db: Pull complete
5f129a65fac7: Pull complete
Digest: sha256:0bb659eafa22cdb9f14bc05d17be97132842eb122eb8ff346ecafe7553f48f22
Status: Downloaded newer image for wordpress:latest
Creating googleserver_mysql.5.7_1
Creating googleserver_wp.spm_1
Attaching to googleserver_mysql.5.7_1, googleserver_wp.spm_1
mysql.5.7_1 | 2017-01-09T11:07:44.271254Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql.5.7_1 | 2017-01-09T11:07:44.278843Z 0 [Note] mysqld (mysqld 5.7.17) starting as process 1 ...
wp.spm_1 | WordPress not found in /var/www/html - copying now...
mysql.5.7_1 | 2017-01-09T11:07:44.347784Z 0 [Note] InnoDB: PUNCH HOLE support available
mysql.5.7_1 | 2017-01-09T11:07:44.347937Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mysql.5.7_1 | 2017-01-09T11:07:44.347956Z 0 [Note] InnoDB: Uses event mutexes
mysql.5.7_1 | 2017-01-09T11:07:44.348024Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
mysql.5.7_1 | 2017-01-09T11:07:44.348048Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
mysql.5.7_1 | 2017-01-09T11:07:44.348060Z 0 [Note] InnoDB: Using Linux native AIO
mysql.5.7_1 | 2017-01-09T11:07:44.356631Z 0 [Note] InnoDB: Number of pools: 1
mysql.5.7_1 | 2017-01-09T11:07:44.367564Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysql.5.7_1 | 2017-01-09T11:07:44.370949Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
mysql.5.7_1 | 2017-01-09T11:07:44.419506Z 0 [Note] InnoDB: Completed initialization of buffer pool
mysql.5.7_1 | 2017-01-09T11:07:44.476953Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
mysql.5.7_1 | 2017-01-09T11:07:44.501029Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
wp.spm_1 | WARNING: /var/www/html is not empty - press Ctrl+C now if this is an error!
wp.spm_1 | + ls -A
wp.spm_1 | wp-content
wp.spm_1 | + sleep 10
mysql.5.7_1 | 2017-01-09T11:07:44.614777Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
mysql.5.7_1 | 2017-01-09T11:07:44.615567Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
mysql.5.7_1 | 2017-01-09T11:07:45.135167Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
mysql.5.7_1 | 2017-01-09T11:07:45.137285Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
mysql.5.7_1 | 2017-01-09T11:07:45.137414Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
mysql.5.7_1 | 2017-01-09T11:07:45.138586Z 0 [Note] InnoDB: Waiting for purge to start
mysql.5.7_1 | 2017-01-09T11:07:45.189557Z 0 [Note] InnoDB: 5.7.17 started; log sequence number 12168868
mysql.5.7_1 | 2017-01-09T11:07:45.194278Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysql.5.7_1 | 2017-01-09T11:07:45.195063Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mysql.5.7_1 | 2017-01-09T11:07:45.223753Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170109 11:07:45
mysql.5.7_1 | 2017-01-09T11:07:45.235736Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
mysql.5.7_1 | 2017-01-09T11:07:45.237375Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
mysql.5.7_1 | 2017-01-09T11:07:45.237759Z 0 [Note] IPv6 is available.
mysql.5.7_1 | 2017-01-09T11:07:45.237877Z 0 [Note] - '::' resolves to '::';
mysql.5.7_1 | 2017-01-09T11:07:45.237961Z 0 [Note] Server socket created on IP: '::'.
mysql.5.7_1 | 2017-01-09T11:07:45.295529Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql.5.7_1 | 2017-01-09T11:07:45.296334Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
mysql.5.7_1 | 2017-01-09T11:07:45.304463Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
mysql.5.7_1 | 2017-01-09T11:07:45.325375Z 0 [Note] Event Scheduler: Loaded 0 events
mysql.5.7_1 | 2017-01-09T11:07:45.326559Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check.
mysql.5.7_1 | 2017-01-09T11:07:45.326653Z 0 [Note] Beginning of list of non-natively partitioned tables
mysql.5.7_1 | 2017-01-09T11:07:45.377612Z 0 [Note] End of list of non-natively partitioned tables
mysql.5.7_1 | 2017-01-09T11:07:45.378560Z 0 [Note] mysqld: ready for connections.
mysql.5.7_1 | Version: '5.7.17' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
wp.spm_1 | Complete! WordPress has been successfully copied to /var/www/html
wp.spm_1 |
wp.spm_1 | Warning: mysqli::mysqli(): (HY000/2002): No such file or directory in - on line 19
wp.spm_1 |
wp.spm_1 | MySQL Connection Error: (2002) No such file or directory
wp.spm_1 |
wp.spm_1 | Warning: mysqli::mysqli(): (HY000/2002): No such file or directory in - on line 19
wp.spm_1 |
wp.spm_1 | MySQL Connection Error: (2002) No such file or directory
I would say the problem is you are linking your wp instance with a database set up in the localhost, but that is not true, as your database is in the server mysql.5.7. I would try the next yaml file: