Last active
August 29, 2015 14:01
-
-
Save mather/bf731146ece8a0b33edb to your computer and use it in GitHub Desktop.
Dockerfile for Debian 7.4 with Chef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# 1: container name | |
# 2: image name | |
set -e | |
docker run -d -P --name $1 $2 | |
echo "Save these to docker_ssh_config" | |
echo "-------------------------------" | |
echo "Hostname $1.docker" | |
echo " Port $(docker port $1 22 | cut -f 2 -d:)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ssh -F docker_ssh_config -p XXX YYY.docker | |
Host *.docker | |
HostName 192.168.59.33 | |
User docker | |
UserKnownHostsFile /dev/null | |
StrictHostKeyChecking no | |
PasswordAuthentication no | |
IdentityFile .docker/id_dsa | |
IdentitiesOnly yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:7.4 | |
MAINTAINER mather <mather314@gmail.com> | |
RUN apt-get update | |
# SSH Server | |
RUN apt-get install -y openssh-server sudo | |
RUN mkdir /var/run/sshd | |
RUN echo 'root:root' | chpasswd | |
# Create 'docker' user | |
RUN useradd -d /home/docker -m -s /bin/bash docker | |
RUN echo 'docker:docker' | chpasswd | |
RUN echo 'docker ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | |
RUN mkdir -p /home/docker/.ssh | |
ADD .docker/id_dsa.pub /home/docker/.ssh/authorized_keys | |
RUN chown -R docker:docker /home/docker | |
RUN chmod 700 /home/docker/.ssh | |
# Chef | |
RUN apt-get install -y curl | |
RUN curl -L https://www.opscode.com/chef/install.sh | bash | |
# Start sshd | |
EXPOSE 22 | |
CMD /usr/sbin/sshd -D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -d .docker ]; then | |
echo '.docker/ already exists. Abort.' | |
exit 1 | |
fi | |
echo 'Creating SSH key for docker...' | |
mkdir .docker | |
ssh-keygen -t dsa -C "Identity key for docker" -f .docker/id_dsa -N '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# 1: container name | |
ssh -F docker_ssh_config -p `docker port $1 22 | cut -f2 -d:` $1.docker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment