Docker container management using best practices

I am considering using both docker and permissions. The idea I had was to use the facility to set my instances, and I was wondering what would be the best thing to do:

  • Call from dockerfile on every container (which would require it to be installed on every container / instance. This method is mentioned in an irreplaceable workbook , in the docker episode); or
  • Launching my containers and then setting up all instances with an executable.

What would be the best approach? Are there other alternative ways for this use?

+3


source to share


1 answer


To use Ansible to set up docker hosts (like instances), you don't need to install Ansible on a remote machine. You install Ansible on your main machine and run downloadable books and custom commands from there. This is why Ansible is a good tool for this kind of task (for example, installation on remote machines).

For example, if your remote docker host is a CentOS 7 machine, you can use the following book to install docker based on the Docker installation guide

- name: Install Docker on remote hosts
  hosts: docker-hosts
  sudo: yes
  tasks:
    - name: Install docker
      shell: curl -sSL https://get.docker.com | sh

      



Note that the group docker-hosts

is defined by your hosts / inventory.

Once you have docker installed on the remote computers, you can create another Ansible bootable workbook to create / run your containers.

We usually use Ansible module shell

instead of module docker

. This is more for convenience and reference. So later someone might look at the shell command you use to deploy containers remotely as an example for your own development (ie, "How do you run this 'start docker' command again?)

+4


source







All Articles