Introduction
Would you like to try Docker effortlessly on a standard Centos or Ubuntu machine? The summary below will take you there. These instructions work both on physical and virtual machines and will get you Docker containers working in a couple of minutes.Installation
Centos 6.xRequirements: EPEL repo, kernel >= 2.6.32-431
yum install docker-ioUbuntu 14.04
service docker start
chkconfig docker on
wget -qO- https://get.docker.com/ | shTest run
docker run hello-world
Ubuntu 14.04 minimal guest
Download image, create a container that stays running, run a shell on it:docker pull ubuntuCreate a non-root user and enable ssh on the container
MYHOSTNAME=ubuntu01
docker create --name=$MYHOSTNAME --hostname=$MYHOSTNAME ubuntu sleep infinity
docker start $MYHOSTNAME
docker exec -it $MYHOSTNAME bash
apt-get updateStop the the container in order to test the startup procedure
apt-get install -y openssh-server
useradd -m -s /bin/bash myuser
passwd myuser
sed -ri 's/^session\s+required\s+pam_loginuid.so$/session optional pam_loginuid.so/' /etc/pam.d/sshd
service ssh start
exit
docker stop $MYHOSTNAMETest the container startup procedure and try to access it using ssh
docker start $MYHOSTNAMEDone! We have a simple procedure to create as many Ubuntu 14.04 general purpose guests as needed using Docker technology.
docker exec $MYHOSTNAME service ssh start
GUESTIP=`docker exec $MYHOSTNAME ip -4 -o addr list eth0 label eth0 | awk '{print $4}' | awk -F/ '{print $1}'`
ssh myuser@$GUESTIP
Final notes
This article aims to be the Docker test drive I haven't found elsewhere. It provides a basic OpenSSH server installation and deals with the exit-after-start nonsense discussed here - the "sleep infinity" command is there to ensure the container stays running until it is explicitly stopped. For other purposes the default behaviour might be better but this is what makes sense in a Docker test drive, especially for people with a virtualization background..
Sem comentários:
Enviar um comentário