-1

I'm trying to start the service "windsribe vpn" and then login. my docker file is able to run the start command etc/init.d/windscribe-cli start to start the service but it skips the command windscribe login,

when I run sudo docker-compose up the output is:

Starting windscribe ... OK

which means it started but it stays there, is not showing any errors.

it doesn't show any other output but should be showing

Windscribe Username: example-username
Windscribe Password: example-password

in the output to login

I'm using the line CMD bash -c "/etc/init.d/windscribe-cli start && windscribe login" and I even try to run other lines like:

CMD bash -c "/etc/init.d/windscribe-cli start && python3 myscript.py" which works for starting the service and running the python script but for some reason it never shows the login output

this is my DockerFile

FROM ubuntu:latest
RUN apt-get update
#install windscribe
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-key FDC247B7
RUN echo 'deb https://repo.windscribe.com/ubuntu bionic main' | tee /etc/apt/sources.list.d/windscribe-repo.list
RUN apt-get -y update
RUN apt-get install -y windscribe-cli 

ENV HOME /home/host

COPY ["./"]

CMD bash -c "/etc/init.d/windscribe-cli start && windscribe login"

and this is my docker-compose.yml

version: "3"
services:
  app:
    image: my-app:latest
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 5s
      restart_policy:
        condition: on-failure
    build: .
    environment:
      - DISPLAY=${DISPLAY}
    volumes:
      - /tmp/.X11-unix:/tmp/.X11-unix
    networks:
      - scrapping
    tty: true
    

networks:
  scrapping:
    ipam:
      driver: default
      config:
        - subnet: 192.168.150.0/24

EDIT here I'm adding the output for the command windscribe status and the cmd line would look like this CMD bash -c "/etc/init.d/windscribe-cli start && windscribe status && windscribe login"

and it's output is:

 Starting windscribe ... OK
 windscribe -- pid: 19, status: running, uptime: 0m, %cpu: 0.0, %mem: 
 0.2
Camilo
  • 419
  • 1
  • 4
  • 9
  • 1
    Please read: [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) --- Please [edit] the post and share all relevant information, e.g. the dockerfile, the docker-compose file and the script that should be executed. – Turing85 Sep 01 '21 at 21:15
  • 1
    "*`CMD bash -c "/etc/init.d/windscribe-cli start && windscribe login"`*" - The second command (`windscribe login`) will only be executed AFTER the first command (`/etc/init.d/windscribe-cli start`) has successfully terminated. – Turing85 Sep 01 '21 at 21:27
  • Is `login` supposed to _ask_ for a username/password? If so, your entrypoint/cmd actions shouldn't be interactive – OneCricketeer Sep 01 '21 at 21:28
  • @Turing85 it ends in the line ```Starting windscribe ... OK``` – Camilo Sep 01 '21 at 21:30
  • @OneCricketeer it should ask for username and password but it's not showing them. – Camilo Sep 01 '21 at 21:32
  • Right, so you have two problems. 1) Something like `/etc/init.d/windscribe-cli start; windscribe login` wont wait for the first command 2) There is no interactive TTY for you to type into when the container starts (unless you do `docker run -ti`) – OneCricketeer Sep 01 '21 at 21:33
  • it is waiting for the first one to end, and it's state is active. I will try the second one but I don't know is there is something similar for docker-compose – Camilo Sep 01 '21 at 21:37
  • I added the output with the command to check the service status ```CMD bash -c "/etc/init.d/windscribe-cli start && windscribe status && windscribe login"```. And the output now is: ```Starting windscribe ... OK windscribe -- pid: 19, status: running, uptime: 0m, %cpu: 0.0, %mem: 0.2 ``` – Camilo Sep 01 '21 at 21:43

2 Answers2

0

Due to && short circuiting, if /etc/init.d/windscribe-cli start fails, windscribe login will never run.

/etc/init.d/windscribe-cli start won't work, because there's no init system in the Ubuntu docker image.

On a best practices note, you will for all practical purposes never find a Docker image with an init system in it.

You can take a look at the windscribe docs and figure out how to run it manually. That's the process you'll want to use in your Docker image.

Swiss
  • 5,556
  • 1
  • 28
  • 42
  • the command ```/etc/init.d/windscribe-cli start``` is working, the output ```Starting windscribe ... OK``` shows that it's now active. – Camilo Sep 01 '21 at 21:34
  • Calling the bash script `/etc/init.d/windscribe-cli` directly is "manual" (although may call other binaries itself)... Using `systemctl`, for example, wouldn't work, but that doesn't seem to be the issue here – OneCricketeer Sep 01 '21 at 21:35
  • It prints that line, but that doesn't mean it's working. Is the process actually starting correctly? What happens if you change the `CMD` to `CMD bash -c "/etc/init.d/windscribe-cli start; echo $?"` – Swiss Sep 01 '21 at 21:36
  • @Swiss yes, it is starting correctly. I will add another output with the command for showing the service status – Camilo Sep 01 '21 at 21:38
  • @Camilo How are you running the docker image? Are you running `docker run -it` ? – Swiss Sep 01 '21 at 21:41
  • @Swiss I'm running it with ```docker-compose up``` – Camilo Sep 01 '21 at 21:42
  • @Camilo `windscribe login` is probably an interactive command, it may not work at all if you use it in an non-interactive shell. Can you run the image manually with `docker run -it` to see if it works when you attach it with an interactive terminal? – Swiss Sep 01 '21 at 21:44
  • it didn't work I'm to search an alternativa for docker-compose – Camilo Sep 01 '21 at 21:55
  • @Swiss i tried with ```docker exec -ti container-id /bin/bash``` to connect to the running container. the login failed so i read again what you said about the init and tried with the command ```systemctl start windscribe``` and the output was ```System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down``` – Camilo Sep 01 '21 at 22:34
  • @Camilo Sorry to get you off on the wrong trail, `systemd` commands won't work, because systemd won't be running in the container. If the `/etc/init.dwindscribe-cli start` command is actually bringing up the process, just stick with that. – Swiss Sep 01 '21 at 22:37
  • @Swiss what did you mean by running it manually? – Camilo Sep 01 '21 at 23:30
  • @Camilo With `docker run -it` instead of with docker-compose. – Swiss Sep 02 '21 at 17:37
0

windscribe login is probably an interactive command, but you are not running the container with the interactive setting. This can cause all kinds of weird behaviors with interactive commands, and may be the cause of what you're seeing.

As per this answer: Interactive shell using Docker Compose

Try adding the interactive setting and see if that fixes the problem:

    stdin_open: true # docker run -i

Or for the full thing:

version: "3"
services:
  app:
    image: my-app:latest
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 5s
      restart_policy:
        condition: on-failure
    build: .
    environment:
      - DISPLAY=${DISPLAY}
    volumes:
      - /tmp/.X11-unix:/tmp/.X11-unix
    networks:
      - scrapping
    stdin_open: true # docker run -i
    tty: true
Swiss
  • 5,556
  • 1
  • 28
  • 42