ubuntu@ip-172-30-2-68:~$ docker network create wordpressnet efff9f7cc3a08cbdd871e1f10d6a0f25515ba1d39c79077e8f7900fb0029e596 ubuntu@ip-172-30-2-68:~$ docker network ls NETWORK ID NAME DRIVER SCOPE d1a42256454b bridge bridge local 7334f900df0e host host local fa6aae724b3d none null local efff9f7cc3a0 wordpressnet bridge local
ubuntu@ip-172-30-2-68:~$ docker volume create wordpress_db_volume wordpress_db_volume ubuntu@ip-172-30-2-68:~$ docker volume ls DRIVER VOLUME NAME local mysqlvolume local wordpress_db_volume
[想定している設定] コンテナ名 wordpress_db [環境変数とここでの値] MYSQL_ROOT_PASSWORD myrootpassword MYSQL_DATABASE wordpressdb MYSQL_USER wordpressuser MYSQL_PASSWORD wordpresspass
ubuntu@ip-172-30-2-68:~$ docker run --name wordpress_db -dit -v wordpress_db_volume:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=myrootpassword -e MYSQL_DATABASE=wordpressdb -e MYSQL_USER=wordpressuser -e MYSQL_PASSWORD=wordpresspass --net wordpressnet mysql:5.7 be559cba742615cb79e0d06a9c0a33158d53c8b6b35f18c0c202f167e68bd211 ubuntu@ip-172-30-2-68:~$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES be559cba7426 mysql:5.7 "docker-entrypoint.s…" 4 seconds ago Up 3 seconds 3306/tcp, 33060/tcp wordpress_db
[環境変数] WORDPRESS_DB_HOST wordpress_db WORDPRESS_DB_NAME wordpressdb WORDPRESS_DB_USER wordpressuser WORDPRESS_DB_PASSWORD wordpresspass
ubuntu@ip-172-30-2-68:~$ docker run --name wordpress_db -dit -v wordpress_db_volume:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=myrootpassword -e MYSQL_DATABASE=wordpressdb -e MYSQL_USER=wordpressuser -e MYSQL_PASSWORD=wordpresspass --net wordpressnet mysql:5.7 be559cba742615cb79e0d06a9c0a33158d53c8b6b35f18c0c202f167e68bd211 ubuntu@ip-172-30-2-68:~$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES be559cba7426 mysql:5.7 "docker-entrypoint.s…" 4 seconds ago Up 3 seconds 3306/tcp, 33060/tcp wordpress_db ubuntu@ip-172-30-2-68:~$ docker run --name wordpress_app -dit -p 8080:80 -e WORDPRESS_DB_HOST=wordpress_db -e WORDPRESS_DB_NAME=word pressdb -e WORDPRESS_DB_USER=wordpressuser -e WORDPRESS_DB_PASSWORD=wordpresspass --net wordpressnet wordpress ebf1185f0ae11d9075e63598cce5397c400c41a9b6fdcb49b35cec6af1be73d5 ubuntu@ip-172-30-2-68:~$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ebf1185f0ae1 wordpress "docker-entrypoint.s…" 13 seconds ago Up 11 seconds 0.0.0.0:8080->80/tcp, :::8080->80/tcp wordpress_app be559cba7426 mysql:5.7 "docker-entrypoint.s…" 6 minutes ago Up 6 minutes 3306/tcp, 33060/tcp wordpress_db
http://35.76.124.169:8080/
ubuntu@ip-172-30-2-68:~$ docker stop wordpress_db wordpress_app wordpress_db wordpress_app ubuntu@ip-172-30-2-68:~$ docker rm wordpress_db wordpress_app wordpress_db wordpress_app ubuntu@ip-172-30-2-68:~$ docker network rm wordpressnet wordpressnet ubuntu@ip-172-30-2-68:~$ docker volume rm wordpress_db_volume wordpress_db_volume
あらかじめコンテナの起動方法やボリューム、ネットワークの構成などを記述した定義ファイル (デフォルトでは docker-compose.yml) を用意しておいて、その定義ファイルからまとめて実行するのが Docker Compose である。
$ sudo apt install -y python3 python3-pip
$ sudo pip3 install docker-compose[エラーが起きた]
Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-build-y54pjucb/cryptography/setup.py", line 17, in from setuptools_rust import RustExtension ModuleNotFoundError: No module named 'setuptools_rust' =============================DEBUG ASSISTANCE========================== If you are seeing an error here please try the following to successfully install cryptography: Upgrade to the latest pip and try again. This will fix errors for most users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip =============================DEBUG ASSISTANCE========================== ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-y54pjucb/cryptography/
$ sudo python3 -m pip install --upgrade pip
$ sudo pip install docker-compose
$ docker-compose --version /usr/local/lib/python3.6/dist-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release. from cryptography.hazmat.backends import default_backend docker-compose version 1.29.2, build unknown
ubuntu@ip-172-30-2-68:~$ mkdir wordpress ubuntu@ip-172-30-2-68:~$ cd wordpress
wordpress/docker-compose.yml |
|
$ cd ~/wordpress $ docker-compose up -d /usr/local/lib/python3.6/dist-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release. from cryptography.hazmat.backends import default_backend Creating network "wordpress_wordpressnet" with the default driver Creating volume "wordpress_wordpress_db_volume" with default driver Creating wordpress_wordpress_db_1 ... done Creating wordpress_wordpress_app_1 ... done
$ docker-compose ps /usr/local/lib/python3.6/dist-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release. from cryptography.hazmat.backends import default_backend Name Command State Ports --------------------------------------------------------------------------------------------------------- wordpress_wordpress_app_1 docker-entrypoint.sh apach ... Up 0.0.0.0:8080->80/tcp,:::8080->80/tcp wordpress_wordpress_db_1 docker-entrypoint.sh mysqld Up 3306/tcp, 33060/tcp
ubuntu@ip-172-30-2-68:~/wordpress$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 143b1bc9558b wordpress "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:8080->80/tcp, :::8080->80/tcp wordpress_wordpress_app_1 00719e2e791d mysql:5.7 "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 3306/tcp, 33060/tcp wordpress_wordpress_db_1 ubuntu@ip-172-30-2-68:~/wordpress$ docker network ls NETWORK ID NAME DRIVER SCOPE d1a42256454b bridge bridge local 7334f900df0e host host local fa6aae724b3d none null local 25e9376c0a99 wordpress_wordpressnet bridge local ubuntu@ip-172-30-2-68:~/wordpress$ docker volume ls DRIVER VOLUME NAME local 57d578464741e0e819fc1f931e8154e5685a3efc5c5b1f1aac388889b317c709 local 563b940b7864e020fab60d6a40858a03dcb2fa3c9a2f64c8c937bf650627ad0d local mysqlvolume local wordpress_wordpress_db_volume
ubuntu@ip-172-30-2-68:~/wordpress$ docker-compose down /usr/local/lib/python3.6/dist-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release. from cryptography.hazmat.backends import default_backend Stopping wordpress_wordpress_app_1 ... done Stopping wordpress_wordpress_db_1 ... done Removing wordpress_wordpress_app_1 ... done Removing wordpress_wordpress_db_1 ... done Removing network wordpress_wordpressnet ubuntu@ip-172-30-2-68:~/wordpress$ docker-compose ps /usr/local/lib/python3.6/dist-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release. from cryptography.hazmat.backends import default_backend Name Command State Ports ------------------------------