Skip to content

Instantly share code, notes, and snippets.

@wataruoguchi
Last active September 10, 2016 04:05
Show Gist options
  • Select an option

  • Save wataruoguchi/3ad4328956f0555a3219f2c2838f36aa to your computer and use it in GitHub Desktop.

Select an option

Save wataruoguchi/3ad4328956f0555a3219f2c2838f36aa to your computer and use it in GitHub Desktop.
Getting Started With Docker

Getting Started with Docker

Foreword

Getting Started with Ansible

Install Docker

On the other day I installed Ansible. I'd like to try installing Docker by using Ansible.

I found this nice repository. I cannot thank enough to open source committers, they are my hero.

Also found the good article. This is written in 2014, but works in 2016!

Firstly, let's install the repository.

sudo ansible-galaxy install angstwad.docker_ubuntu

Then change the hosts file. [local] is a group name.

vi /etc/ansible/hosts
-127.0.0.1
+[local]
+localhost

Next, let's create my first Ansible playbook in yml.

vi /tmp/docker.yml
- hosts: local
  connection: local
  roles:
    - angstwad.docker_ubuntu

Then, execute ansible-playbook with the playbook

sudo ansible-playbook /tmp/docker.yml

Done! Docker is installed! I don't think this process can be easier!

docker --version
Docker version 1.12.1, build 23cf638

Run Ubuntu with Docker. This sounds little odd, because I am running Ubuntu Docker Image on Ubuntu in VirtualBox.

sudo docker pull ubuntu
sudo docker run -it ubuntu

And it worked!

Test some Docker commands

Make a directory on ubuntu on Docker

mkdir ~/test

Exit

exit

Re-login

sudo docker run -it ubuntu
ls

You can see there is no test you made.

sudo docker ps -a

You can save the state with docker commit

Delete a docker image

docker rmi -f <image_name>

Delete all docker containers

sudo docker rm `sudo docker ps -a -q`

I deleted all containers, but can easily get the new container. This is the Try and Destroy environment!

sudo docker pull ubuntu

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment