Thursday 3 March 2016

Docker: Part 2 - Ubuntu Installation

You can install docker by following below commands
  1. wget -qO- https://get.docker.com/ | sh 
    The above command downloads and executes a small installation script written by the Docker team.
  2. Docker daemon will be run automatically after installation. To check whether it is running, use following command
    sudo service docker status
  3. The docker daemon binds to a Unix socket (/var/run/docker.sock) instead of a TCP port. By default that Unix socket is owned by the user root and other users can access it with sudo.
    For this reason, docker daemon always runs as the root user.
  4. "docker" binary acting as a client of daemon also needs to be run as a root.
  5. To avoid having to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.
    sudo usermod -aG docker <user>
  6. We can use -H/--host flag (specify daemon socket to connect to) to specify different interface and port configuration. For example, binding to the network
    sudo /usr/bin/docker -d -H tcp://0.0.0.0:2375
    above command would bind to all interfaces of host.
  7. Client will not become informed about interface change automatically. You have to pass -H flag while running commands
    docker -H :2375
  8. If you do NOT want to give the -H flag in every command, you can export environment variable export
    DOCKER_HOST="tcp://0.0.0.0:2375"
Finally, verify the installation using
docker run hello-world

No comments:

Post a Comment