T1; Dr; WordPressドッカーを作成しようとすると、別のドッカー作成コンテナと通信するためのコンテナが作成されます。共有MySQLコンテナの使用
私のMacには、WordPress &があります。これは、リンクされたMySQLサーバで構築して設定したMySQLコンテナです。私はGoogle Cloud MySQLストレージインスタンスを使用する予定ですので、docker-composeファイルからMySQLコンテナを削除(リンクを解除)してから、複数のdockerコンテナから使用できる共有コンテナを分離してください。
問題は、WordPressコンテナを別のMySQLコンテナに接続できないことです。誰かが私がこれについてどうやって行くかもしれないかについてどのような光を当てることができるだろうか?
Iローカルボックスは、/ etc/hostsファイルを介して参照(私の好ましい構成私はENVに応じてファイルを更新することができるように)
を有することネットワークを作成しようとして失敗しただけでなく、固定IPを作成しようとしていますWP:
version: '2'
services:
wordpress:
container_name: spmfrontend
hostname: spmfrontend
domainname: spmfrontend.local
image: wordpress:latest
restart: always
ports:
- 8080:80
# creates an entry in /etc/hosts
extra_hosts:
- "ic-mysql.local:172.20.0.1"
# Sets up the env, passwords etc
environment:
WORDPRESS_DB_HOST: ic-mysql.local:9306
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: root
WORDPRESS_DB_NAME: wordpress
WORDPRESS_TABLE_PREFIX: spm
# sets the working directory
working_dir: /var/www/html
# creates a link to the volume local to the file
volumes:
- ./wp-content:/var/www/html/wp-content
# Any networks the container should be associated with
networks:
default:
external:
name: ic-network
のMySQL:
version: '2'
services:
mysql:
container_name: ic-mysql
hostname: ic-mysql
domainname: ic-mysql.local
restart: always
image: mysql:5.7
ports:
- 9306:3306
# Create a static IP for the container
networks:
ipv4_address: 172.20.0.1
# Sets up the env, passwords etc
environment:
MYSQL_ROOT_PASSWORD: root # TODO: Change this
MYSQL_USER: root
MYSQL_PASS: root
MYSQL_DATABASE: wordpress
# saves /var/lib/mysql to persistant volume
volumes:
- perstvol:/var/lib/mysql
- backups:/backups
# creates a volume to persist data
volumes:
perstvol:
backups:
# Any networks the container should be associated with
networks:
default:
external:
name: ic-network
docker-compose.yamlを私たちと共有できますか? –
@YaronIdan WPインスタンスのドッカーファイルを含むように更新しました – gazzwi86
これはドッカーファイルではなく、ドッカーのcompose.yamlです。そしてなぜそれはmysqlコンテナを含んでいないのですか? –