Skip to content

Commit

Permalink
Merge pull request google#38 from google/docker-fixes
Browse files Browse the repository at this point in the history
Docker fixes
  • Loading branch information
adelva1984 committed Jan 7, 2020
2 parents 18e5ea6 + 24d9876 commit 8440e2d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
8 changes: 4 additions & 4 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ scp *.img vsoc-01@$CF:~/

You can boot Cuttlefish from the container as follows:

```bash
ssh vsoc-01@$CF -L localhost:6520:127.0.0.1:6520 -L localhost:6444:127.0.0.1:6444
bin/launch_cvd -cpus 4 -memory_mb 4096
```
ssh vsoc-01@$CF \
-L localhost:6520:127.0.0.1:6520 \
-L localhost:6444:127.0.0.1:6444 \
-- bin/launch_cvd -cpus 4 -memory_mb 4096

The above example launches Cuttlefish with 4 cores and 4GB of RAM, while also setting up an SSH tunnel that allows you to connect to Cuttlefish via ADB and VNC from outside the container:

Expand Down
14 changes: 5 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is based on https://hub.docker.com/r/jrei/systemd-debian/.

FROM debian:buster
FROM debian:buster-slim

ENV container docker
ENV LC_ALL C
Expand All @@ -27,7 +27,9 @@ CMD ["/lib/systemd/systemd"]
RUN apt update \
&& apt install -y apt-utils sudo vim dpkg-dev devscripts gawk coreutils \
openssh-server openssh-client psmisc iptables iproute2 dnsmasq \
net-tools rsyslog qemu-system-x86 equivs
net-tools rsyslog equivs # qemu-system-x86

RUN dpkg -l

COPY . /root/android-cuttlefish/

Expand All @@ -39,15 +41,9 @@ RUN cd /root/android-cuttlefish \
RUN apt-get clean \
&& rm -rf /root/android-cuttlefish

RUN groupadd kvm

RUN useradd -ms /bin/bash vsoc-01 -d /home/vsoc-01 -G kvm,cvdnetwork \
&& passwd -d vsoc-01 \
&& echo 'vsoc-01 ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers \
&& echo 'sudo chmod ug+rw /dev/kvm' >> /home/vsoc-01/.bashrc \
&& echo 'sudo chmod ug+rw /dev/vhost-vsock' >> /home/vsoc-01/.bashrc \
&& echo 'sudo chown root.kvm /dev/kvm' >> /home/vsoc-01/.bashrc \
&& echo 'sudo chown root.cvdnetwork /dev/vhost-vsock' >> /home/vsoc-01/.bashrc
&& echo 'vsoc-01 ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

RUN sed -i -r -e 's/^#{0,1}\s*PasswordAuthentication\s+(yes|no)/PasswordAuthentication yes/g' /etc/ssh/sshd_config \
&& sed -i -r -e 's/^#{0,1}\s*PermitEmptyPasswords\s+(yes|no)/PermitEmptyPasswords yes/g' /etc/ssh/sshd_config \
Expand Down
8 changes: 8 additions & 0 deletions debian/cuttlefish-common.init
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ start() {
create_legacy_interfaces $i
create_interfaces $i
done
# When running inside a privileged container, set the ownership and access
# of these device nodes.
if test -f /.dockerenv; then
chown root.kvm /dev/kvm
chown root.cvdnetwork /dev/vhost-vsock
chmod ug+rw /dev/kvm
chmod ug+rw /dev/vhost-vsock
fi
}

stop() {
Expand Down
6 changes: 6 additions & 0 deletions debian/cuttlefish-common.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ case "$1" in
addgroup --system cvdnetwork
fi

# Create the kvm group when running inside a docker container.
if test -f /.dockerenv && ( ! getent group kvm > /dev/null 2>&1 )
then
addgroup --system kvm
fi

# Automatically added by dh_installinit
if [ -x "/etc/init.d/cuttlefish-common" ] || [ -e "/etc/init/cuttlefish-common.conf" ]; then
if [ ! -e "/etc/init/cuttlefish-common.conf" ]; then
Expand Down

0 comments on commit 8440e2d

Please sign in to comment.