UFO ET IT

Docker 머신 위치 변경-Windows

ufoet 2020. 12. 10. 20:46
반응형

Docker 머신 위치 변경-Windows


Windows 7에서 docker 도구 상자를 사용하여 docker를 실행하고 있습니다. (Docker 버전 1.9.1)

도커 머신은 C : \ Users \ username \ .docker \ machine \ machines \ default에 VM을 생성합니다. 그리고 이미지를 커밋하면이 위치에서 VM 크기가 커집니다. Windows 이후로 C 드라이브에 여유 공간이 없습니다.

기본 컴퓨터의 위치를 ​​변경할 수있는 방법이 있습니까?


이것은 Windows 7에서 완벽하게 작동했습니다.

  1. MACHINE_STORAGE_PATH 환경 변수를 Docker 머신 / VM, 캐시 등에 사용할 위치의 루트로 설정합니다.
  2. Docker Toolbox 설치
  3. Docker 빠른 시작 터미널 실행

Docker Toolbox는 이제 MACHINE_STORAGE_PATH가 가리키는 위치에 모든 파일을 생성합니다.

최신 정보:

Docker 빠른 시작 터미널 스크립트가 "default"라는 이름이 아닌 항목에서는 작동하지 않는 것처럼 보이기 때문에 새 저장소 경로로 새 VM을 만드는 것은 이상적이지 않습니다.

C : 드라이브에 이미 VM이있는 경우 가장 간단한 방법은 Oracle VirtualBox로 이동하여 "기본"VM을 삭제하고 Docker Toolbox를 제거하고 C : \ Users \ <username>을 삭제하는 것입니다. docker \를 입력 한 다음 위의 3 단계를 따릅니다.

참고 : Docker Toolbox를 제거하고 다시 설치할 필요가 없습니다. 그러나 나는 그것 없이는 테스트하지 않았습니다.

최신 정보

Docker 인증서도 이동하려면 DOCKER_CERT_PATH새 드라이브의 경로를 가리 키도록 변수를 설정하십시오 . 팁을 위해 @Nutle에게 감사드립니다.


.docker디렉터리를 다른 드라이브 로 이동 하고 연결 지점을 만들 수 있습니다.

일반 바로 가기는 작동하지 않습니다.

예를 들면 :

.docker에서 다음 C:\Users\username으로 디렉토리 이동D:\

다음을 실행하십시오.

C:\Users\username>mklink /j .docker D:\.docker
Junction created for .docker <<===>> D:\.docker

2015 년부터 현재 (2017 년 6 월) Hyper-V 를 사용하여 VHDX파일 위치를 정의 할 수 있습니다 .

Windows 용 Docker 1.13.0, 2017-01-19 (안정)를 참조하십시오 .

이미지 및 비 호스트 마운트 볼륨이 포함 된 VHDX 파일을 이동할 수 있습니다 (UI의 "고급"탭 사용).

다음 %APPDATA%\Docker\settings.json과 같이 수정합니다 .

"MobyVhdPathOverride":"C:\\Users\\Public\\Documents\\Hyper-V\\New folder\\MobyLinuxVM.vhdx"

https://cdn-enterprise.discourse.org/docker/uploads/default/optimized/2X/6/6193445cf15811ce18317c727af258adb2d16c9d_1_690x447.jpg

자세한 내용은 이 스레드를 참조하십시오 .


원래 답변

현재 2015 년 고정 표시기 기계의 힘의 사용 %USERPROFILE%:
참조libmachine/mcnutils/utils.go#L17-L25

499 호 에서 언급 한대로 :

그동안 사용자는 .docker/machine/*파일이 저장 되는 위치를 어떻게 지정할 수 있습니까?

--storage-path명령 줄에서 지정 하거나 환경 변수를 사용하여 할 수 있습니다 MACHINE_STORAGE_PATH.

( PR 1941 에서 구현 된 것을 볼 수 있습니다. )

Joost Den Boer 는 의견에서 지적 합니다.

-s <path>Mac에서 ' '을 (를) 시도했는데 제대로 작동하는 것 같습니다.
분명하지 않은 것은 경로 옵션이 명령 앞에 있다는 것 입니다.
" docker-machine -s /Volumes/other/location' create --driver=virtualbox"을 (를) 실행 하면 다른 위치에 새 VirtualBox 이미지가 생성되었습니다.


VirtualBox 그래픽 인터페이스를 사용하여 파일을 재배치하십시오 disk.vmdk.

여기에 이미지 설명 입력

  1. 파일 C:\Users\{myUsername}\.docker\machine\machines\default\disk.vmdk을 다른 폴더에 복사합니다 F:\docker-image\.
  2. 열기 VirtualBox, defaultVM을 선택 하고 엽니 다 Settings.
  3. 을 열고 Storage현재를 선택 disk.vmdk하고 해제 (또는 삭제)합니다.
  4. 를 클릭 Choose Virtual Hard Disk File...하고 복사 된 파일을 검색하십시오.F:\docker-image\
  5. 경고 발생 : VirtualBox가 이전 VM UID에 대해 불평 한 다음 메뉴로 이동하여 이전 항목 File을 선택 Virtual Media Manager...하고 해제하거나 제거disk.vmdk
  6. 재시도 4., 완료되었습니다!
  7. 환경에 따라 필요한 경우 boot2docker.iso, 스냅 샷 폴더, 비디오 캡처에 대해서도 재배치를 수행하십시오.

Docker 빠른 시작 터미널을 실행할 때 다음 두 명령을 입력하십시오.

새 위치는 "D : \ docker"이고 새 컴퓨터 이름은 "docker1"이라고 가정합니다.

export MACHINE_STORAGE_PATH=D:\\docker

docker-machine create --driver=virtualbox docker1

그러면 새 위치에 지정된 이름으로 새 컴퓨터가 생성됩니다.


MACHINE_STORAGE_PATH 환경 변수 메서드가 작동하도록 할 수 없습니다. 기기를 처음 초기화 할 때 인증서 누락에 대해 계속 불평했습니다. 여전히 Windows 7에서는 docker-toolbox를 사용해야합니다.

다음과 같이 문제를 해결했습니다.

  1. Uninstalling Docker Toolbox and restarting machine
  2. Open up Administrator prompt (Find command prompt, hold shift, choose "Run As Administrator")
  3. Deleting .docker from %USERPROFILE%: rmdir /S %USERPROFILE%.docker
  4. Create folder called .docker elsewhere: mkdir a:\.docker
  5. mklink /J %USERPROFILE%.docker a:\.docker
  6. Close Admin command prompt
  7. Reinstall Docker Toolbox
  8. Use the Docker Quickstart Terminal link to bootstrap everything.
  9. Kitematic can be opened now too (though I had to choose the "Use Virtual Box" option on first error.

I have had a bit of trouble with any of the solutions above but this is what worked for me:

  • define the MACHINE_STORAGE_PATH environment variable to point to your desired directory/folder.
  • Install docker-toolbox as normal, if this works for you then fine, but for me it was still installing inside .docker directory.
  • To fix this I have then stopped and removed the default machine that was created along with .docker folder from the Users directory.
  • Edited the start.sh script and added the line at the top:

e.g.

export MACHINE_STORAGE_PATH=D:\\Docker
  • Run the Docker Quickstart Terminal Shortcut, which rebuilt the default machine inside the desired folder

These answers are out of date, as of the latest release. The location is configurable in the Settings user interface.

https://github.com/docker/for-win/issues/333


I found lots of these answers were out of data, at least they did not work in my environment: win10 PRO, docker desktop community 2.0.0.3. Finally, I resolved this problem by this method:

  1. uninstall docker

  2. open Hyper-V manager (press WIN key and then enter "Hyper")

  3. Change the default virtual hard disk locations in the Hyper-V settings (not on the VM settings) and confirm

  4. install docker

  5. check the disk image location in advanced options of docker settings


Create file called c:\programdata\docker\config\daemon.json with content below where e:\images is location where do you want to store all you images etc. restart docker.

{ "graph": "e:\images" }

This Worked like a charm

Reference - https://forums.docker.com/t/where-are-images-stored/9794/11

참고URL : https://stackoverflow.com/questions/33933107/change-docker-machine-location-windows

반응형