patternMinor
Why screen folder in /var/run disappears in Docker container after running Ansible playbook?
Viewed 0 times
aftervarwhycontainerdockerplaybookdisappearsrunningfolderscreen
Problem
Files
I've got the following
and the following
Build
Now, I build the Docker container in a shell by:
and the Configure screen task shows the following output:
then my
I've got the following
Dockerfile:FROM ansible/ansible:ubuntu1604py3
ENV DEBIAN_FRONTEND noninteractive
RUN pip3 install ansible
RUN printf '[local]\r\nlocalhost ansible_python_interpreter="env python3"\r\n' > /etc/ansible/hosts
ADD . /opt
RUN ansible-playbook /opt/install_screen.yml -c local -v
RUN useradd -d /home/ubuntu -ms /bin/bash -g root -G sudo -p ubuntu ubuntu
USER ubuntu
WORKDIR /home/ubuntu
CMD ["/usr/bin/env", "screen"]and the following
install_screen.yml playbook file:- hosts: localhost
tasks:
- name: Install screen (a full-screen window manager)
apt: name=screen state=present
register: screen_installed
- name: Configure screen
shell: bash -x /etc/init.d/screen-cleanup start
register: screen_configured
when: screen_installed is success
- shell: ls -la /var/run/Build
Now, I build the Docker container in a shell by:
$ docker build -t screen .and the Configure screen task shows the following output:
changed: [localhost] => {"changed": true, "cmd": "bash -x /etc/init.d/screen-cleanup start", "delta": "0:00:00.009613", "end": "2018-05-01 23:09:49.159514", "rc": 0, "start": "2018-05-01 23:09:49.149901", "stderr": "+ set -e\n+ test -f /usr/bin/screen\n+ SCREENDIR=/var/run/screen\n+ case \"$1\" in\n+ test -L /var/run/screen\n+ test -d /var/run/screen\n+ find /var/run/screen -type p -delete\n++ stat -c%a /usr/bin/screen\n+ BINARYPERM=2755\n+ '[' 2755 -ge 4000 ']'\n+ '[' 2755 -ge 2000 ']'\n+ chmod 0775 /var/run/screen\n+ exit 0", "stderr_lines": ["+ set -e", "+ test -f /usr/bin/screen", "+ SCREENDIR=/var/run/screen", "+ case \"$1\" in", "+ test -L /var/run/screen", "+ test -d /var/run/screen", "+ find /var/run/screen -type p -delete", "++ stat -c%a /usr/bin/screen", "+ BINARYPERM=2755", "+ '[' 2755 -ge 4000 ']'", "+ '[' 2755 -ge 2000 ']'", "+ chmod 0775 /var/run/screen", "+ exit 0"], "stdout": "", "stdout_lines": []}then my
ls -la /var/run/ shell command shows:Solution
Rather than solving the immediate problem you're having, let me suggest an alternative solution to your actual problem:
I need screen, so I can use multiple interactive shells in one instance of Docker. If I run multiple Docker instances, each takes 1G of RAM, so 10+ instances will kill my RAM.
Run screen (or tmux, but screen if you insist) locally on your workstation. Start up your docker container, and in the windows where you want to do something on the container, use
You may also want to look into using Vagrant with the Docker provider to simplify the process of doing development on a Docker container.
I need screen, so I can use multiple interactive shells in one instance of Docker. If I run multiple Docker instances, each takes 1G of RAM, so 10+ instances will kill my RAM.
Run screen (or tmux, but screen if you insist) locally on your workstation. Start up your docker container, and in the windows where you want to do something on the container, use
docker exec -it bash to get a new interactive shell on the container. This will be much simpler than running screen inside the container, and allows you to also have windows running commands on your workstation.You may also want to look into using Vagrant with the Docker provider to simplify the process of doing development on a Docker container.
Context
StackExchange DevOps Q#4041, answer score: 2
Revisions (0)
No revisions yet.