Docker: how to restart process inside of container?

I have a set of tests which I would like to run on docker container.
In the middle of the tests I am changing me test data and I need to restart JETTY.

What is the best way to do that?

  • Difference between 2 varieties of Dockerfiles for running a nodejs app
  • Docker run command with environment variables
  • Cannot return to shell session after script
  • Docker container running tomcat - could not access the server using the host IP address
  • Setting up Docker Postgres inside Python container
  • Cannot use Version 2 docker-compose files on Vagrant
  • I can imagine some options:

    1. With SSH – but for the docker ssh is not the best option.

    2. Python agent on docker to listen sockets – expose one more port, connect and restart jetty.

    Maybe there are better ideas for that?


  • ECS: Environment variables set in task but not present in container
  • Simple Python Docker Script
  • Fail join node to docker swarm
  • Vagrant and docker Protocol error mounting directory windows 7
  • Docker - Mount Directory From Container to Host
  • Zabbix server and agent using dns with docker swarm 1.12- connection problems
  • 2 Solutions collect form web for “Docker: how to restart process inside of container?”

    Sounds like the process you’re trying to restart is the primary process for the docker container (ie. the one you set in your Dockerfile if you have one, and when you run ‘ps -ef’ inside the container you would see the PID for your process set to 1). If this is the case, then you cannot restart it from inside the container. You should just restart the container itself:

    docker restart <container_id>

    Enter the container and restart it.

    Manual Way:

    docker exec -it <containeridorname> /bin/bash

    Or Automated Way:

    docker exec -it <containeridorname> /
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.