Ubuntu 12.04 - Set Docker To Use the LXC Container Engine

As of Docker 0.9, docker does not use LXC by default for the container engine. However, one may find it useful to do so, in order to attach to running containers with a new TTY.

Method 1 - Installation Script

Simply copy the following script into a file and execute it with

sudo bash my-script.sh
#!/bin/bash

# Ensure running bash not sh etc
if ! [ -n "$BASH_VERSION" ];then
    echo "this is not bash, calling self with bash....";
    SCRIPT=$(readlink -f "$0")
    /bin/bash $SCRIPT
    exit;
fi

# Ensure running as root user
USER=`whoami`

if [ "$USER" != "root" ]; then
        echo "You need to run me with sudo!"
        exit
fi

apt-get update && apt-get install lxc -y
echo 'DOCKER_OPTS="-e lxc"' >> /etc/default/docker
service docker restart

Method 2 - Manual Steps

    Ensure that you already have LXC installed by running the following command
    sudo apt-get install lxc -y
    Edit the /etc/default/docker file and adding "-e lxc" as shown below:
    Restart the docker service by running
    sudo service docker restart
    or by rebooting the server

References

No comments:

Post a Comment