-
Notifications
You must be signed in to change notification settings - Fork 52
/
Dockerfile.ubuntu
49 lines (42 loc) · 1.68 KB
/
Dockerfile.ubuntu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
FROM ubuntu:jammy
LABEL MAINTAINER="John Rofrano <[email protected]>"
ENV DEBIAN_FRONTEND noninteractive
# Install packages needed for SSH and interactive OS
RUN apt-get update && \
yes | unminimize && \
apt-get -y install \
openssh-server \
passwd \
sudo \
man-db \
curl \
wget \
vim-tiny && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Enable systemd (from Matthew Warman's mcwarman/vagrant-provider)
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*; \
rm -f /etc/systemd/system/*.wants/*; \
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*; \
rm -f /lib/systemd/system/anaconda.target.wants/*;
# Enable ssh for vagrant
RUN systemctl enable ssh.service;
EXPOSE 22
# Create the vagrant user
RUN useradd -m -G sudo -s /bin/bash vagrant && \
echo "vagrant:vagrant" | chpasswd && \
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/vagrant && \
chmod 440 /etc/sudoers.d/vagrant
# Establish ssh keys for vagrant
RUN mkdir -p /home/vagrant/.ssh; \
chmod 700 /home/vagrant/.ssh
ADD https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub /home/vagrant/.ssh/authorized_keys
RUN chmod 600 /home/vagrant/.ssh/authorized_keys; \
chown -R vagrant:vagrant /home/vagrant/.ssh
# Run the init daemon
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]