Help us understand the problem. What is going on with this article?

Docker toolbox on windows マウント:Dockerコンテナの中でホストのフォルダを見たい

More than 3 years have passed since last update.

1. Virtualbox shared folder 設定

以下のように設定。
Folder Nameを覚えておく。

image

docker-machine ssh default 'sudo mkdir -p /e'
docker-machine ssh default 'sudo mount -t vboxsf -o uid=0,gid=0 E_DRIVE /e'

# dockerホストにマウントした共有フォルダをData Volumeとして利用する
docker run -v /e:/e busybox ls -la /e

docker run と exec

dockerrun.bash
docker run -v /work2:/work2 -it --name work2 hnishi/ubuntu14.04_gromacs-4.6.6:mpi_v1.0_pb07  #/work2を利用できるコンテナを作成

一度コンテナを抜けた後にもう一度入りたい↓

dockerexec.bash
#!/bin/bash -eu
id=`docker ps -ql`  #最後に起動したコンテナ
docker start $id && docker exec -it $id /bin/bash  #終了したコンテナの再起動とbashを実行

2. Docker machineを起動するたびに自動でマウントする

/mnt/sda1/var/lib/boot2docker/bootlocal.sh にコマンドを書いておくと
Dockerマシンを起動したときに自動でコマンドを実行する。

docker-machine ssh default
sudo tee /mnt/sda1/var/lib/boot2docker/bootlocal.sh <<-'EOF'
mkdir -p /e
mount -t vboxsf -o uid=0,gid=0 E_DRIVE /e
EOF

参考

Dockerにホストのフォルダをマウントしたい!
http://qiita.com/dojineko/items/f623894ef2436bef890e
Docker MachineでDドライブなどUsers以外を自動マウントする
http://qiita.com/Bakudankun/items/d612865440565b10523f

hnishi
AWS SA Associate/AWS ML Specialty
access
SDNからセンサ、家電、電子書籍まで。ACCESSはあらゆるレイヤのデバイス、サービスを「繋げて」いきます。
http://jp.access-company.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした