How To Run Salt-Minion In Docker Container
In this post we will use a Ubuntu based docker image in which I have already installed the salt-minion and uploaded it into docker hub. Now if you are looking for installing the salt-minion in docker container from scratch then check out my other guide.
Here I am assuming that you are having Ubuntu host up and running with public IP configured on it.
Here I am assuming that you are having Ubuntu host up and running with public IP configured on it.
Pull the docker image
$ docker pull yogeshprasadkurmi/ubuntu-salt-minion |
---|
This is a Ubuntu 14.04.5 based image with salt-minion installed on it. Salt-minion will be up and running if you create the container using this images.
Create salt minion agent
$ docker run -ti --name salt-minion-agent --net=none --privileged=true yogeshprasadkurmi/ubuntu-salt-minion bash |
---|
This will create a container with salt-minion installed on it.
Assigning an IP for a container
Here I am assuming that host machine is having interface "eth0" with public IP configured. Name of the container is salt-minion-agent. The below steps needs to be performed on the docker host.
Create a virtual interface
$ ip link add name veth0 link eth0 type macvlan mode bridge New virtual interface "veth0" will be createdGet the process id for the salt minion container
$ docker inspect -f '{{.State.Pid}}' salt-minion-agent Create Link
$ mkdir -p /var/run/netns $ ln -s /proc/<processid>/ns/net /var/run/netns/<processid>
Assign the virtual interface to salt-minion-agent
$ ip link set veth0 netns <processid> name eth0 Get the public Ip to virtual interface
$ docker exec -it salt-minion-agent dhclient -v eth0
Note: If you are facing any issue on assigning the static public IP to the container then check out this guide
Configure salt minion to connect to salt master
This needs to be run inside the container(salt-minion-agent)
- Edit the minion configuration file (/etc/salt/minion) and search for "master:" and update with the salt-master IP e.g. master: 10.10.98.90
Restart the salt-minion service
$ service salt-minion restart
Comments
Post a Comment