2
0
mirror of https://github.com/linka-cloud/d2vm.git synced 2025-06-23 13:52:26 +00:00

fix: dockerfile relative path when running in docker

docs: update README.md to current command line api
fix: command line output white for default level

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
2022-09-10 19:31:40 +02:00
parent d97b58159c
commit a41be6d27c
7 changed files with 79 additions and 90 deletions

View File

@ -1,5 +1,4 @@
FROM debian
RUN apt update && apt install -y openssh-server systemctl && \
systemctl enable ssh && \
RUN apt update && apt install -y openssh-server && \
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config

View File

@ -1,6 +1,6 @@
# d2vm full example
# ZSH Workstation example
This example demonstrate the setup of a ZSH workstation.
This example demonstrate the setup of a ZSH workstation with *cloud-init* support.
*Dockerfile*
```dockerfile
@ -9,14 +9,11 @@ FROM ubuntu
# Install some system packages
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
qemu-guest-agent \
netplan.io \
ca-certificates \
dnsutils \
sudo \
openssh-server
# Setup default network config
COPY 00-netconf.yaml /etc/netplan/
# Add a utility script to resize serial terminal
COPY resize /usr/local/bin/
@ -33,7 +30,10 @@ RUN DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
git \
vim \
tmux \
htop
htop \
lsb-core \
cloud-init \
cloud-guest-utils
# Create user with sudo privileged and passwordless sudo
RUN useradd ${USER} -m -s /bin/zsh -G sudo && \
@ -54,23 +54,11 @@ RUN bash -c "$(curl -fsSL https://gist.githubusercontent.com/Adphi/f3ce3cc4b2551
RUN bash -c "$(curl -fsSL https://gist.githubusercontent.com/Adphi/765e9382dd5e547633be567e2eb72476/raw/a3fe4b3f35e598dca90e2dd45d30dc1753447a48/tmux-setup)"
# Setup auto login serial console
RUN sudo sed -i "s|ExecStart=.*|ExecStart=-/sbin/agetty --autologin ${USER} --keep-baud 115200,38400,9600 \%I \$TERM|" /usr/lib/systemd/system/serial-getty@.service
```
*00-netconf.yaml*
```yaml
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: true
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
```
There is no need to configure the network as **d2vm** will generate a *netplan* configuration that use DHCP.
**Build**
```bash
@ -78,23 +66,29 @@ USER=mygithubuser
PASSWORD=mysecurepasswordthatIwillneverusebecauseIuseMostlySSHkeys
OUTPUT=workstation.qcow2
d2vm build -o $OUTPUT --force --build-arg USER=$USER --build-arg PASSWORD=$PASSWORD --build-arg SSH_KEY=https://github.com/$USER.keys .
d2vm build -o $OUTPUT --build-arg USER=$USER --build-arg PASSWORD=$PASSWORD --build-arg SSH_KEY=https://github.com/$USER.keys --force -v .
```
Run it using *libvirt's virt-install*:
Run it:
```bash
virt-install --name workstation --disk $OUTPUT --import --memory 4096 --vcpus 4 --nographics --cpu host --channel unix,target.type=virtio,target.name='org.qemu.guest_agent.0'
d2vm run qemu --mem 4096 --cpus 4 $IMAGE
```
... you should be automatically logged in with a **oh-my-zsh** shell
From an other terminal you should be able to find the VM ip address using:
You should be able to find the ip address inside the VM using:
```bash
virsh domifaddr --domain workstation
hostname -I
# or
ip a show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1
```
And connect using ssh...
In order to quit the terminal you need to shut down the VM with the `poweroff` command:
```bash
sudo poweroff
```
*I hope you will find it useful and that you will have fun...*

View File

@ -1,5 +1,4 @@
FROM ubuntu
RUN apt update && apt install -y openssh-server systemctl && \
systemctl enable ssh && \
RUN apt update && apt install -y openssh-server && \
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config