laradockとMySQLの接続が上手くいかず
以下の記事を参考にlaradock_mysqlを消去しましたが
再構築が上手くいきません。
https://qiita.com/dnrsm/items/4bd078c17bb0d6888647
docker-compose build mysqlで再構築を試したがexitが表示される
$ docker-compose build mysql Building mysql Step 1/10 : ARG MYSQL_VERSION=latest Step 2/10 : FROM mysql:${MYSQL_VERSION} ---> cd3ed0dfff7e Step 3/10 : LABEL maintainer="Mahmoud Zalt <mahmoud@zalt.me>" ---> Using cache ---> ad1eaddfdd3c Step 4/10 : ARG TZ=UTC ---> Using cache ---> 85de8f5edbf4 Step 5/10 : ENV TZ ${TZ} ---> Using cache ---> 4bb2c4140532 Step 6/10 : RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && chown -R mysql:root /var/lib/mysql/ ---> Using cache ---> 274222389848 Step 7/10 : COPY my.cnf /etc/mysql/conf.d/my.cnf ---> Using cache ---> 1d03f5dedba6 Step 8/10 : RUN chmod 0444 /etc/mysql/conf.d/my.cnf ---> Using cache ---> ffaa008e0e2b Step 9/10 : CMD ["mysqld"] ---> Using cache ---> d98731378b70 Step 10/10 : EXPOSE 3306 ---> Using cache ---> c8991e074e96 Successfully built c8991e074e96 Successfully tagged laradock_mysql:latest mullan-mac:laradock @@@$ docker-compose ps Name Command State Ports ------------------------------------------------------------------------------------------------------------------ laradock_beanstalkd_1 /usr/bin/beanstalkd Exit 137 laradock_docker-in-docker_1 dockerd-entrypoint.sh Up 2375/tcp, 2376/tcp laradock_mysql_1 docker-entrypoint.sh mysqld Exit 2 laradock_nginx_1 /bin/bash /opt/startup.sh Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp laradock_php-fpm_1 docker-php-entrypoint php-fpm Up 9000/tcp laradock_phpmyadmin_1 /docker-entrypoint.sh apac ... Up 0.0.0.0:8080->80/tcp laradock_redis_1 docker-entrypoint.sh redis ... Exit 0 laradock_workspace_1 /sbin/my_init Up 0.0.0.0:2222->22/tcp
docker-compose up -d nginx mysql phpmyadminで試したがmysqlのみ表示されない
$ docker-compose up -d nginx mysql phpmyadmin Starting laradock_mysql_1 ... laradock_docker-in-docker_1 is up-to-date laradock_workspace_1 is up-to-date laradock_php-fpm_1 is up-to-date Starting laradock_mysql_1 ... done Starting laradock_phpmyadmin_1 ... done mullan-mac:laradock @@@$ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 285e1a3ee342 laradock_phpmyadmin "/docker-entrypoint.…" 12 minutes ago Up 11 seconds 0.0.0.0:8080->80/tcp laradock_phpmyadmin_1 e18f799feb80 laradock_nginx "/bin/bash /opt/star…" 26 hours ago Up 2 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp laradock_nginx_1 3cfac25ab736 laradock_php-fpm "docker-php-entrypoi…" 26 hours ago Up 2 minutes 9000/tcp laradock_php-fpm_1 0fce26e9732d laradock_workspace "/sbin/my_init" 26 hours ago Up 2 minutes 0.0.0.0:2222->22/tcp laradock_workspace_1 5acb64003410 docker:dind "dockerd-entrypoint.…" 26 hours ago Up 2 minutes 2375-2376/tcp
もしお分かりになる方がいらっしゃいましたら
ご教授いただきたいです。
よろしくお願い致します。
--no-cacheをつけて再構築を試してみた結果
$ docker-compose build --no-cache mysql Building mysql Step 1/10 : ARG MYSQL_VERSION=latest Step 2/10 : FROM mysql:${MYSQL_VERSION} ---> cd3ed0dfff7e Step 3/10 : LABEL maintainer="Mahmoud Zalt <mahmoud@zalt.me>" ---> Running in daab6ea0794a Removing intermediate container daab6ea0794a ---> 1943a8fddde6 Step 4/10 : ARG TZ=UTC ---> Running in ac35f7f65558 Removing intermediate container ac35f7f65558 ---> c582f5b86d99 Step 5/10 : ENV TZ ${TZ} ---> Running in 0ff53fa7230c Removing intermediate container 0ff53fa7230c ---> d652c99ce8c3 Step 6/10 : RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && chown -R mysql:root /var/lib/mysql/ ---> Running in a95b1b2ed26c Removing intermediate container a95b1b2ed26c ---> 2b2cec091ed8 Step 7/10 : COPY my.cnf /etc/mysql/conf.d/my.cnf ---> 95ecaebf8ed7 Step 8/10 : RUN chmod 0444 /etc/mysql/conf.d/my.cnf ---> Running in 3cfaecc4da23 Removing intermediate container 3cfaecc4da23 ---> a6b8123a6bd7 Step 9/10 : CMD ["mysqld"] ---> Running in b981de656294 Removing intermediate container b981de656294 ---> b31c4377bc5d Step 10/10 : EXPOSE 3306 ---> Running in ca50eda84f9b Removing intermediate container ca50eda84f9b ---> ca92f3ca91cc Successfully built ca92f3ca91cc Successfully tagged laradock_mysql:latest mullan-mac:laradock @@@$ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 285e1a3ee342 laradock_phpmyadmin "/docker-entrypoint.…" About an hour ago Up 54 minutes 0.0.0.0:8080->80/tcp laradock_phpmyadmin_1 e18f799feb80 laradock_nginx "/bin/bash /opt/star…" 27 hours ago Up 56 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp laradock_nginx_1 3cfac25ab736 laradock_php-fpm "docker-php-entrypoi…" 27 hours ago Up 56 minutes 9000/tcp laradock_php-fpm_1 0fce26e9732d laradock_workspace "/sbin/my_init" 27 hours ago Up 56 minutes 0.0.0.0:2222->22/tcp laradock_workspace_1 5acb64003410 docker:dind "dockerd-entrypoint.…" 27 hours ago Up 56 minutes 2375-2376/tcp
<追記> docker-compose.yml 文字数制限のためMySQL部分のみの表示です
version: '3' networks: frontend: driver: ${NETWORKS_DRIVER} backend: driver: ${NETWORKS_DRIVER} volumes: mysql: driver: ${VOLUMES_DRIVER} percona: driver: ${VOLUMES_DRIVER} mssql: driver: ${VOLUMES_DRIVER} postgres: driver: ${VOLUMES_DRIVER} memcached: driver: ${VOLUMES_DRIVER} redis: driver: ${VOLUMES_DRIVER} neo4j: driver: ${VOLUMES_DRIVER} mariadb: driver: ${VOLUMES_DRIVER} mongo: driver: ${VOLUMES_DRIVER} minio: driver: ${VOLUMES_DRIVER} rethinkdb: driver: ${VOLUMES_DRIVER} phpmyadmin: driver: ${VOLUMES_DRIVER} adminer: driver: ${VOLUMES_DRIVER} aerospike: driver: ${VOLUMES_DRIVER} caddy: driver: ${VOLUMES_DRIVER} elasticsearch: driver: ${VOLUMES_DRIVER} mosquitto: driver: ${VOLUMES_DRIVER} confluence: driver: ${VOLUMES_DRIVER} sonarqube: driver: ${VOLUMES_DRIVER} cassandra: driver: ${VOLUMES_DRIVER} services: ### MySQL ################################################ mysql: build: context: ./mysql args: - MYSQL_VERSION=${MYSQL_VERSION} environment: - MYSQL_DATABASE=${MYSQL_DATABASE} - MYSQL_USER=${MYSQL_USER} - MYSQL_PASSWORD=${MYSQL_PASSWORD} - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} - TZ=${WORKSPACE_TIMEZONE} volumes: - ${DATA_PATH_HOST}/mysql:/var/lib/mysql - ${MYSQL_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d ports: - "${MYSQL_PORT}:3306" networks: - backend
https://qiita.com/J_Shell/items/695a30fd38444d065ae5
こちらの記事でも試しましたが、
applicationsのvolumesの記載がなかったため変更ができず
何も触っていません。