데스크톱 환경에서 가상 컴퓨터를 실행하기 위해 vagrant 사용
우리 회사의 개발 환경은 VirtualBox에서 실행되는 가상 머신을 기반으로합니다. 한 단계 더 나아가서 Vagrant의 기능을 사용하여 컴퓨터에 대한 설명을 텍스트 파일로 만든 다음 해당 텍스트 파일을 기반으로 해당 시스템을 "올릴 수"있습니다. 꼭두각시와 결합하면 모든 사람이 VM에 다른 소프트웨어 버전이 설치되어 있다는 문제를 해결할 수 있습니다.
그러나 Vagrant는 호스트를 개발하는 데 매우 집중하여 백그라운드에서 기계를 사용할 수있게합니다. 우리는 기계 내에 개발 환경이 필요하므로 완전한 GUI가 필요합니다. 따라서 "유기"를 입력하면 완전한 데스크탑 환경 (XFCE, KDE ...)이있는 기계가 나타납니다.
지금까지 Xubuntu 배포판에서 "기본"상자를 만들었습니다. 그러나 "vagrant up"을 입력하면 바탕 화면이 나타나고 제대로 로그인 할 수 있지만 Vagrant는 "컴퓨터 부팅 대기 중입니다. 몇 분 정도 걸릴 수 있습니다 ..."메시지가 표시됩니다. 잠시 후 Vagrant가 시간 초과로 인해 충돌합니다. 따라서 공유 폴더가 생성되지 않거나 패키지 프로 비저 -puppet-이 실행되지 않습니다.
방랑자를 사용하여 완전한 GUI로 가상 머신을 작성하는 방법은 무엇입니까?
방금 기본적으로 세 단계로 작업했습니다. 의 조언 askubuntu.com
이 나에게 효과적이지 않았 으므로이 단순화 된 버전을 사용해보십시오.
- 기본 우분투 이미지 작업을하십시오. 부팅 할 수 있어야합니다
vagrant ssh
. - 그런 다음 VirtualBox 디스플레이를 활성화합니다 (기본적으로 꺼져 있음). VM을 중지하고 다음 행을 주석 해제하십시오
Vagrantfile
.config.vm.provider : virtualbox do | vb | vb.gui = true 종료
- VM을 부팅하고 새 디스플레이 창을 관찰하십시오. 이제 설치하고 시작하면
xfce4
됩니다. 사용vagrant ssh
및 :sudo apt-get 설치 xfce4 sudo startxfce4 &
그게 다야, 당신은 xfce4
세션에 착륙해야합니다 .
업데이트 : 더 나은 경험을 위해 다음 개선 사항을 권장합니다.
- 루트로 GUI를 시작하지 마십시오. 당신은 정말로
vagrant
사용자 를 유지하고 싶습니다 . 이렇게하려면 누구나 GUI를 시작sudo vim /etc/X11/Xwrapper.config
하고 편집 할 수 있도록해야합니다allowed_users=anybody
. - 다음으로 GUI 를 시작 하기 전에 VirtualBox 게스트 도구 를 설치하십시오 . 이것은 건강한 화면 해상도, 통합 마우스 등을 제공합니다.
$ sudo apt-get 설치 -y xfce4 virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11 $ sudo VBoxClient-all
- 으로 만 GUI를
vagrant
사용자 로 시작해야합니다$ startxfce4&
.
업데이트 2 : 오늘 이것을 시도하고 VBoxClient-all
스크립트가 항상 설치되는 것은 아닙니다. 누락 된 경우 해당 항목으로 바꿀 수 있습니다.
sudo VBoxClient-클립 보드 sudo VBoxClient-드래그 앤 드롭 sudo VBoxClient-디스플레이 sudo VBoxClient --checkhostversion sudo VBoxClient-완벽한
다음은 Air의 탁월한 답변입니다. Vagrantfile
Vagrant.configure(2) do |config|
# Ubuntu 15.10
config.vm.box = "ubuntu/wily64"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
end
# Install xfce and virtualbox additions
config.vm.provision "shell", inline: "sudo apt-get update"
config.vm.provision "shell", inline: "sudo apt-get install -y xfce4 virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11"
# Permit anyone to start the GUI
config.vm.provision "shell", inline: "sudo sed -i 's/allowed_users=.*$/allowed_users=anybody/' /etc/X11/Xwrapper.config"
end
vm을 시작하려면
vagrant up
virtualbox GUI의 로그인 프롬프트를 통해 username : vagrant
, password : vagrant
로 로그인하십시오.
xfce 시작
startx
내 2 센트
버그를 피하려면 최신 방랑자 (1.3.3) + VirtualBox (4.2.18)를 실행해야합니다.
쉘 스크립트 또는 인라인 명령을 사용하여 데스크탑 환경 또는 경량 창 관리자를 설치할 수 있습니다
For example install LXDE on top of Ubuntu 12.04 Precise base box from vagrantbox.es
Vagrant.configure("2") do |config|
# ... other configuration
config.vm.provision "shell" do |s|
s.inline = "apt-get install lubuntu-desktop -y"
end
end
- If you build your own vagrant base boxes, make sure you follow the base box packaging instructions or consider tools like packer (or veewee) to automate the build.
I'm using ubuntu desktop image, it works nicely with two monitors on windows with virtual box provider.
Vagrant.configure(2) do |config|
config.vm.box = "box-cutter/ubuntu1404-desktop"
config.ssh.forward_agent = true
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.synced_folder "../../git", "/home/vagrant/git"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.customize ["modifyvm", :id, "--monitorcount", "2"]
vb.memory = "2048"
end
end
Here is a slightly adapted Vagrantfile for Ubuntu 18.04 LTS / bionic - thanks to Air's and Nik's answers, and this post explaining how to increase the disk size when using VirtualBox (default = 10 GB).
The VM includes a LightDM login screen.
Update: I've created a GitHub repo from this example, and added many software packages for frontend + backend development.
# Optional - enlarge disk:
#vagrant plugin install vagrant-disksize
vagrant up
vagrant reload
# After reboot, the VM screen should show the LightDM login screen.
# Log in as user "vagrant", password "vagrant".
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/bionic64"
# Optional - enlarge disk (will also convert the format from VMDK to VDI):
#config.disksize.size = "50GB"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
end
# https://askubuntu.com/questions/1067929/on-18-04-package-virtualbox-guest-utils-does-not-exist
config.vm.provision "shell", inline: "sudo apt-add-repository multiverse && sudo apt-get update"
# Install xfce and virtualbox additions.
# (Not sure if these packages could be helpful as well: virtualbox-guest-utils-hwe virtualbox-guest-x11-hwe)
config.vm.provision "shell", inline: "sudo apt-get install -y xfce4 virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11"
# Permit anyone to start the GUI
config.vm.provision "shell", inline: "sudo sed -i 's/allowed_users=.*$/allowed_users=anybody/' /etc/X11/Xwrapper.config"
# Optional: Use LightDM login screen (-> not required to run "startx")
config.vm.provision "shell", inline: "sudo apt-get install -y lightdm lightdm-gtk-greeter"
# Optional: Install a more feature-rich applications menu
config.vm.provision "shell", inline: "sudo apt-get install -y xfce4-whiskermenu-plugin"
end
You might also consider using Packer to create VirtualBox images for developers to use.
Rather than sharing the Vagrantfile which developers each use to build and run their VM, you would have a packer template (json) which is used to create a VM image. Developers download or copy the image and run it locally, directly in VB, without having to build it themselves.
Many of the publicly shared Vagrant base boxes are created with Packer.
After installing the desktop, you'll also want to install GDM which will let you boot directly into a graphical environment. You'll also want to configure it.
So maybe add this?
Vagrant::Config.run do |config|
config.vm.provision :shell, :inline => "sudo apt-get install gdm"
config.vm.provision :shell, :inline => "sudo dpkg-reconfigure gdm"
end
Adding to billmalarky's comment above, on fedora 20 the following was necessary before starting xfce:
- Install VirtualBox-guest.rpm (available from rpmfusion repos)
- yum groups mark install 'graphical_environment'
- yum groupinstall "Xfce"
- yum install xorg-x11-drivers
Here is the code:
config.vm.provision "shell", inline: <<-SHELL
#Install Virtual Box guest additions from rpmfusion repos
cd /vagrant
yum install -y rpmfusion-free-release-20.noarch.rpm
yum install -y rpmfusion-nonfree-release-20.noarch.rpm
yum update -y
yum install -y VirtualBox-guest
#Add XFCE desktop to fedora server
yum groups mark install 'graphical_environment'
yum groupinstall -y "Xfce"
yum install -y xorg-x11-drivers
SHELL
Like the xfce4
solution by @Air. Once I had success, but today I failed with ubuntu16.04. I got this error:
xrdb can't open display 1
But luckily, I found this works:
startx
I've patched Nik's answer a bit to avoid HTTP 404:
Vagrant.configure(2) do |config|
# Ubuntu 15.10
config.vm.box = "bento/ubuntu-18.04"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
end
# Install xfce and virtualbox additions
config.vm.provision "shell", inline: "sudo apt-get update"
config.vm.provision "shell", inline: "sudo apt-get install -y xfce4 virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11"
# Permit anyone to start the GUI
config.vm.provision "shell", inline: "sudo sed -i 's/allowed_users=.*$/allowed_users=anybody/' /etc/X11/Xwrapper.config"
end
'Programming' 카테고리의 다른 글
PHP-스트림을 열지 못했습니다 : 해당 파일이나 디렉토리가 없습니다 (0) | 2020.06.19 |
---|---|
파이썬에서 exit (0)과 exit (1)의 차이점 (0) | 2020.06.19 |
리스트의리스트를 초기화하는 파이썬 (0) | 2020.06.19 |
기존 ASP.NET MVC (5) 웹 응용 프로그램 프로젝트에 웹 API를 추가하는 방법은 무엇입니까? (0) | 2020.06.19 |
무중단 프로세스 란 무엇입니까? (0) | 2020.06.19 |