Last active
February 15, 2018 07:35
-
-
Save onokatio/161c317ba9a8032e40d71e5477839713 to your computer and use it in GitHub Desktop.
Dockerのデータ永続化関連について ref: https://qiita.com/onokatio/items/fcc9f8f94f8533bb030a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ docker run -v /host/path:/container/path image-name | |
| # ホストの/host/pathとコンテナ内の/container/pathを同期してimage-nameを起動 | |
| $ docker run -v /host/path:/container/path:ro image-name | |
| # ホストの/host/pathとコンテナ内の/container/pathをリードオンリーで同期してimage-nameを起動。コンテナ側からはファイルの変更ができない。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ docker run -v ./public:/usr/share/nginx/html:ro nginx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ docker volume create volume-name | |
| # volume-nameという名前で保存領域を作成します。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ docker volume create database-data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ docker run -v volume-data:/container/path image | |
| # コンテナ内の/container/pathディレクトリがvolume-dataと同期される用になります。 | |
| $ docker run -v volume-data:/container/path:ro image | |
| # コンテナ内の/container/pathディレクトリがリードオンリーでvolume-dataに保管される用になります。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ docker run -v database-data:/var/lib/mysql mysql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ docker -v /path/to/directory:/path/to/directory --name data-volume image /bin/true | |
| # これで、data-volumeという名前で、ホストとコンテナ内を同期するコンテナを起動できます。 | |
| $ docker --volumes-from data-volume image | |
| # これで、data-volumeがマウントしているボリュームを同じようにマウントします。つまり`v /path/to/directory:/path/to/directory`を指定したことになります。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ docker volume create --driver vieux/sshfs -o [email protected]:/path/to/directory -o password=password sshvolume |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment