How to share files with Docker Toolbox

Introduction

If you mount any folder on your local PC in the container launched by Docker You can freely put files in the closed NW in docker! I think, and summarize the results of my research

Why are you posting such an article now?

If you search for "Docker windows file sharing" on google, you'll be killed instantly. ・ When I looked at the content of the article, it was actually for Docker for Windows (* PCs that cannot run Hyper-V clients are not helpful because they use the Docker environment with Docker Toolbox). -Although there was a virtualbox setting (described later), the format of the command method on docker after that was ambiguous, so I did not understand well after all. I didn't like the environment I was in, so I had a hard time, so Leave it in the article so that you can start over even if the PC flies.

Procedure (overview)

I don't know from just the outline, but the point is that there are 3 steps in total, so I'll leave it as a memo.

    1. Set up shared folders in Virtualbox
  1. Create a shared folder for the container with Docker Machine, and 1. Mount the shared folder of
    1. Mount the container in the shared folder for the container and any directory of the container and start it.

Procedure (details)

1. 1. Set up shared folders in Virtualbox

    1. Start Oracle VM VirtualBox
  1. default → right click → settings
    1. Click on shared folder
  2. Click the Add New Shared Folder icon on the right side of the window that pops up
  3. Enter the following contents and click "OK" Folder path: Enter the folder path of the local PC you want to use as a shared folder Example) C: \ Users \ watya \ work \ docker Folder name: Folder name when docker-machine recognizes it The point is to replace it with C: \ → / C /, \ → / Example) / C / Users / watya / work / docker image.png

2. Create a shared folder for the container with Docker Machine, and 1. Mount the shared folder of

Start Docker Quickstart Terminal and execute the command. Use the following command to add 1. Mount the shared folder set in. With this, file sharing is connected by the connection of local PC → VirtualBox → Docker machine. The directory name created on the Docker Machine side is e, but anything is fine as long as it is not covered. Personally, I like it because it looks like a drive number and it is easy to understand that it is a shared folder.

DockerToolbox


$ docker-machine ssh default 'sudo mkdir -p /e'
$ docker-machine ssh default 'sudo mount -t vboxsf -o uid=0,gid=0 /C/Users/watya/work/docker /e'

image.png

3. 3. Mount the container in the shared folder for the container and any directory of the container and start it.

Execute the command from Docker Toolbox. With the following command, 2. / E created in is mounted in / home of nginx container.

DockerToolbox


$ docker run -d -v /e:/home --name nginx nginx

If you log in for confirmation and check the contents of / home, you can confirm that it is mounted safely

image.png

Note: Set to mount automatically when Docker Machine starts

Reference URL

The sites referred to this time are as follows. I mean, this is more polite and the explanation of the contents is deeper, so if you don't understand well, I would like to come back from time to time. https://humo-life.net/memo/doku.php?id=%E3%82%BD%E3%83%95%E3%83%88%E3%82%A6%E3%82%A7%E3%82%A2:docker:docker_toolbox%E3%81%A7%E3%83%9E%E3%82%A6%E3%83%B3%E3%83%88_%E5%85%B1%E6%9C%89%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80_%E8%A8%AD%E5%AE%9A

Recommended Posts

How to share files with Docker Toolbox
How to start Camunda with Docker
[Rails] How to use rails console with docker
How to run Blazor (C #) with Docker
How to build Rails 6 environment with Docker
How to install Docker
How to update pre-built files in docker container
How to give your image to someone with docker
How to use docker compose with NVIDIA Jetson
How to get resource files out with spring-boot
How to use nginx-ingress-controller with Docker for Mac
[Rails] How to build an environment with Docker
How to build docker environment with Gradle for intelliJ
[Docker environment] How to deal with ActiveSupport :: MessageEncryptor :: InvalidMessage
How to set Docker nginx
How to number (number) with html.erb
How to delete untagged images in bulk with Docker
How to update with activerecord-import
How to make Laravel faster with Docker for Mac
[Docker + Rails] How to deal with Rails server startup failure
How to rollback migration files
[Part 1] How to deploy Docker containers and static files with CircleCI + ECS + ECR + CloudFront
How to run only specific files with gem's rake test
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Express ~
How to get started with Gatsby (TypeScript) x Netlify x Docker
How to build Rails, Postgres, ElasticSearch development environment with Docker
How to use mysql with M1 mac Docker preview version
How to get started with slim
Run SQL Server with Docker ToolBox
How to disassemble Java class files
How to enclose any character with "~"
How to run JavaFX on Docker
How to use mssql-tools with alpine
How to decompile java class files
[Artifactory] How to use Docker repository
How to get along with Rails
Update MySQL from 5.7 to 8.0 with Docker
How to build CloudStack using Docker
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ MySQL edition ~
How to install Pry after building Rails development environment with Docker
How to run a job with docker login in AWS batch
How to place and share SwiftLint config files on the server
How to build Rails + Vue + MySQL environment with Docker [2020/09 latest version]
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Sequelize ~
[For those who create portfolios] How to use binding.pry with Docker
How to crop an image with libGDX
How to adjustTextPosition with iOS Keyboard Extension
How to use binding.pry for view files
How to compile Java with VsCode & Ant
[Java] How to compare with equals method
Run Embulk on Docker to convert files
[Android] How to deal with dark themes
How to use BootStrap with Play Framework
How to switch thumbnail images with JavaScript
Deploy to heroku with Docker (Rails 6, MySQL)
[Note] How to get started with Rspec
How to use Docker in VSCode DevContainer
[Java] How to output and write files!
How to do API-based control with cancancan
Introduced vscode with apt to docker: ubuntu
How to achieve file download with Feign