-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.alpine
More file actions
29 lines (23 loc) · 990 Bytes
/
Dockerfile.alpine
File metadata and controls
29 lines (23 loc) · 990 Bytes
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
FROM alpine:3.16.0
# Use an older Alpine base so core packages remain behind the current v3.16
# repositories and `apk list -u` reports pending updates.
RUN apk add --no-cache \
openssh-server sudo bash \
curl wget vim git nano \
htop tree zip unzip jq && \
mkdir -p /run/sshd
# Configure SSH
RUN sed -i 's/^#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
sed -i 's/^#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config && \
echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config
# Create test user with sudo
RUN adduser -D -s /bin/bash testuser && \
echo 'testuser:testpass' | chpasswd && \
echo 'testuser ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/testuser && \
chmod 440 /etc/sudoers.d/testuser
# Fail the build early if sudo is not usable for the test user.
RUN su - testuser -c "sudo -n true"
# Generate host keys
RUN ssh-keygen -A
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]