Dockerfiles

FROM alpine:latest
ENV ANSIBLE_VERSION 2.15.3

RUN apk update; \
    apk add gcc python3; \
    apk add python3-pip; \
    apk add cmd:pip3 \ # pull whatever package provides the pip3 command. 
    apk add openssh-client; \
    apk cache clean
    
# add Cisco Algorithms to ssh_config
RUN echo 'KexAlgorithms diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1' >> /etc/ssh/ssh_config
RUN echo 'HostKeyAlgorithms ssh-rsa' >> /etc/ssh/ssh_config

# install ansible and pyats
RUN pip3 install --upgrade pip; \
    pip3 install "ansible==${ANSIBLE_VERSION}"; \
    pip3 install ansible
RUN pip3 install pyats
docker build -t ansible:2. .

Restart a stopped container

docker restart <container_name>