-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerfile-devos-gpu
104 lines (92 loc) · 3.4 KB
/
dockerfile-devos-gpu
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
ARG BASE_IMAGE="nvidia/cuda:12.6.1-cudnn-runtime-ubuntu24.04"
FROM $BASE_IMAGE AS base_image
ARG DEBIAN_FRONTEND noninteractive
ARG USER=admin
# Set timezone
ENV LANGUAGE=C.UTF-8
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV TZ=Etc/UTC
# Install build tools
RUN apt-get update && \
apt-get install -y \
apt-utils \
ca-certificates \
curl \
wget \
git \
gnupg2
# Add user
RUN adduser $USER --disabled-password --gecos ''
RUN apt-get install -y sudo && \
echo "$USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/$USER && \
chmod 440 /etc/sudoers.d/$USER
# Install SSH server
RUN apt-get install -y \
openssh-server && \
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
# Install Docker and NVIDIA runtime
RUN install -m 0755 -d /etc/apt/keyrings && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && \
chmod a+r /etc/apt/keyrings/docker.asc && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null && \
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && \
curl -sL https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
tee /etc/apt/sources.list.d/nvidia-container-toolkit.list && \
apt-get update && \
apt-get install -y \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin \
nvidia-container-runtime
RUN echo '{' > /etc/docker/daemon.json && \
echo ' "runtimes": {' >> /etc/docker/daemon.json && \
echo ' "nvidia": {' >> /etc/docker/daemon.json && \
echo ' "path": "nvidia-container-runtime",' >> /etc/docker/daemon.json && \
echo ' "runtimeArgs": []' >> /etc/docker/daemon.json && \
echo ' }' >> /etc/docker/daemon.json && \
echo ' },' >> /etc/docker/daemon.json && \
echo " \"data-root\": \"/home/$USER/.docker_data_root\"" >> /etc/docker/daemon.json && \
echo '}' >> /etc/docker/daemon.json
# Install Visual Studio Code CLI
RUN curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' --output vscode_cli.tar.gz && \
tar -zxvf vscode_cli.tar.gz && \
mv code /usr/local/bin/ && \
rm vscode_cli.tar.gz
# Install dependency components.
RUN apt-get install -y \
iproute2 \
iputils-ping \
netcat-openbsd \
nmap \
socat \
vim
# Clean up
RUN apt-get -y autoclean && \
apt-get -y autoremove && \
rm -rf /var/lib/apt/lists/* \
/var/tmp/* \
/tmp/*
# Create docker init script
RUN echo '#!/bin/bash' > /.dockerinit && \
echo 'set -x' >> /.dockerinit && \
echo 'sudo chown `whoami`:`whoami` $HOME' >> /.dockerinit && \
echo 'sudo service ssh start' >> /.dockerinit && \
echo 'cp -n /etc/skel/.bashrc /etc/skel/.profile /etc/skel/.bash_logout $HOME/' >> /.dockerinit && \
echo 'if [ -f ~/.startup ]; then' >> /.dockerinit && \
echo ' . ~/.startup' >> /.dockerinit && \
echo 'fi' >> /.dockerinit && \
echo 'set -ex' >> /.dockerinit && \
echo 'exec "$@"' >> /.dockerinit && \
chmod 755 /.dockerinit
USER $USER
WORKDIR /home/$USER
VOLUME "/home/$USER"
EXPOSE 22
CMD "/bin/bash"
ENTRYPOINT ["/.dockerinit"]