-
Notifications
You must be signed in to change notification settings - Fork 4
/
install_docker.yml
64 lines (52 loc) · 1.57 KB
/
install_docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---
- name: Install Docker
hosts: nuc
become: true
tasks:
- name: Update apt cache
apt:
update_cache: yes
- name: Install required packages
apt:
name: ['ca-certificates', 'curl', 'gnupg']
- name: Create keyrings directory
file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
- name: Add Docker GPG key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
keyring: /etc/apt/keyrings/docker.gpg
- name: Add Docker APT repository
apt_repository:
repo: deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable
filename: docker
- name: Update apt cache again with new repository
apt:
update_cache: yes
- name: Install Docker
apt:
name: ['docker-ce', 'docker-ce-cli', 'containerd.io', 'docker-buildx-plugin', 'docker-compose-plugin']
- name: Ensure Docker service is running
systemd:
name: docker
enabled: yes
state: started
- name: Pull hello-world Docker image
docker_image:
name: hello-world
source: pull
- name: Run hello-world container
docker_container:
name: hello-world-container
image: hello-world
state: started
- name: Remove hello-world container
docker_container:
name: hello-world-container
state: absent
- name: Create Docker network
docker_network:
name: home_bridge
driver: bridge