Last active
January 23, 2025 19:49
-
-
Save edlee123/cf3fa567fd71992c4bea587034c988df to your computer and use it in GitHub Desktop.
docker_install
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 1. Install Ansible | |
| # sudo apt update | |
| # sudo apt install software-properties-common | |
| # sudo add-apt-repository --yes --update ppa:ansible/ansible | |
| # sudo apt install ansible -y | |
| # 2. | |
| # sudo ansible-playbook docker_install.yml | |
| --- | |
| - name: Docker Install | |
| hosts: localhost | |
| # Modify the TAG variable to the desired version of the OPEA containers: https://hub.docker.com/u/opea | |
| vars: | |
| TAG: "v0.9" | |
| tasks: | |
| - name: Install pre-requisite packages | |
| ansible.builtin.apt: | |
| pkg: | |
| - apt-transport-https | |
| - ca-certificates | |
| - curl | |
| - gnupg | |
| - lsb-release | |
| - software-properties-common | |
| state: present | |
| update_cache: true | |
| - name: Add Docker's GPG key to system | |
| shell: | | |
| install -m 0755 -d /etc/apt/keyrings | |
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | |
| chmod a+r /etc/apt/keyrings/docker.asc | |
| - name: Add Docker repository to apt sources | |
| shell: | | |
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null | |
| - name: Run the equivalent of "apt-get update" as a separate step | |
| ansible.builtin.apt: | |
| update_cache: yes | |
| - name: Install Docker | |
| apt: | |
| name: | |
| - docker-ce | |
| - docker-ce-cli | |
| - containerd.io | |
| - docker-buildx-plugin | |
| - docker-compose-plugin | |
| - name: Create docker group if it doesn't exist | |
| ansible.builtin.group: | |
| name: docker | |
| state: present | |
| - name: Add current user to docker group | |
| ansible.builtin.user: | |
| name: "{{ ansible_user_id }}" | |
| groups: docker | |
| append: yes | |
| - name: Refresh user groups | |
| ansible.builtin.shell: newgrp docker | |
| become: yes | |
| become_user: "{{ ansible_user_id }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment