How can we run a command on another linked container from existing containerHow is Docker different from a virtual machine?How to list containers in DockerHow to get a Docker container's IP address from the host?How to remove old Docker containersCopying files from Docker container to hostCopying files from host to Docker containerHow to copy Docker images from one host to another without using a repositoryHow do I run a command on an already existing Docker container?docker-compose does not update resolv.confDocker container killed after Ctrl +C

Are all Ringwraiths called Nazgûl in LotR?

How did Gollum enter Moria?

What is the highest voltage from the power supply a Raspberry Pi 3 B can handle without getting damaged?

King or Queen-Which piece is which?

Understanding the reasoning of the woman who agreed with Shlomo to "cut the baby in half"

Do I need a shock-proof watch for cycling?

Why is it recommended to mix yogurt starter with a small amount of milk before adding to the entire batch?

"Permanent resident of UK” for a British travel insurance in the US

Is declining an undergraduate award which causes me discomfort appropriate?

Similarity score: Can Sklearn SVR predict values greater than 1 and less than 0?

Can humans ever directly see a few photons at a time? Can a human see a single photon?

Why does the Saturn V have standalone inter-stage rings?

What is the meaning of "понаехать"?

Putting a plot inside a tab

Why is it easier to balance a non-moving bike standing up than sitting down?

Should I include an appendix for inessential, yet related worldbuilding to my story?

What is "industrial ethernet"?

Loss of power when I remove item from the outlet

Is it illegal to withhold someone's passport and green card in California?

Cut the gold chain

Can Ogre clerics use Purify Food and Drink on humanoid characters?

I found a password with hashcat, but it doesn't work

Designing a magic-compatible polearm

Get list of shortcodes from content



How can we run a command on another linked container from existing container


How is Docker different from a virtual machine?How to list containers in DockerHow to get a Docker container's IP address from the host?How to remove old Docker containersCopying files from Docker container to hostCopying files from host to Docker containerHow to copy Docker images from one host to another without using a repositoryHow do I run a command on an already existing Docker container?docker-compose does not update resolv.confDocker container killed after Ctrl +C






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have 2 containers up and running.



i am logged in into one container say container A, I want to execute command x in container B from container A.



To elaborate,



My application has php, mysql and other tools in another container. When user clicks specific link on my php app, a specific command should run on the 3rd container.



My first Container's Dockerfile:



FROM php:7.1.2-apache
RUN docker-php-ext-install mysqli

RUN a2enmod rewrite
RUN /etc/init.d/apache2 restart

ADD . /var/www/html


My second container's Dockerfile:



FROM ubuntu:bionic
RUN apt-get update && apt-get upgrade -y
EXPOSE 5000



My docker-compose.yml file is



version: "2"

services:
www:
build: .
container_name: Web
ports:
- "80:80"
restart: always
command: tail -f /dev/null
volumes:
- .:/var/www/html
- /var/run/docker.sock:/var/run/docker.sock
networks:
internal:
shared:
ipv4_address: 172.55.0.5

ubuntu:
build:
context: ./dockerFiles/ubuntu
container_name: Radius
ports:
- "5000:5000"
volumes:
- ./dockerFiles/radius/ubuntu:/ubuntu
restart: always
networks:
internal:
shared:
ipv4_address: 172.55.0.4

volumes:
persistent:

networks:
internal:
driver_opts:
internal: "true"
driver: bridge
shared:
driver_opts:
enable_ipv6: "true"
driver: bridge
ipam:
config:
- subnet: 172.55.0.0/16
gateway: 172.55.0.1




Is this possible? If yes, can this be eloberated?



Many Thanks in Advance



I have tried docker-in-docker command, this doesn't seems stable and secure.



Expecting to run a command in another container which is linked to this and should be run through php if possible.










share|improve this question






























    0















    I have 2 containers up and running.



    i am logged in into one container say container A, I want to execute command x in container B from container A.



    To elaborate,



    My application has php, mysql and other tools in another container. When user clicks specific link on my php app, a specific command should run on the 3rd container.



    My first Container's Dockerfile:



    FROM php:7.1.2-apache
    RUN docker-php-ext-install mysqli

    RUN a2enmod rewrite
    RUN /etc/init.d/apache2 restart

    ADD . /var/www/html


    My second container's Dockerfile:



    FROM ubuntu:bionic
    RUN apt-get update && apt-get upgrade -y
    EXPOSE 5000



    My docker-compose.yml file is



    version: "2"

    services:
    www:
    build: .
    container_name: Web
    ports:
    - "80:80"
    restart: always
    command: tail -f /dev/null
    volumes:
    - .:/var/www/html
    - /var/run/docker.sock:/var/run/docker.sock
    networks:
    internal:
    shared:
    ipv4_address: 172.55.0.5

    ubuntu:
    build:
    context: ./dockerFiles/ubuntu
    container_name: Radius
    ports:
    - "5000:5000"
    volumes:
    - ./dockerFiles/radius/ubuntu:/ubuntu
    restart: always
    networks:
    internal:
    shared:
    ipv4_address: 172.55.0.4

    volumes:
    persistent:

    networks:
    internal:
    driver_opts:
    internal: "true"
    driver: bridge
    shared:
    driver_opts:
    enable_ipv6: "true"
    driver: bridge
    ipam:
    config:
    - subnet: 172.55.0.0/16
    gateway: 172.55.0.1




    Is this possible? If yes, can this be eloberated?



    Many Thanks in Advance



    I have tried docker-in-docker command, this doesn't seems stable and secure.



    Expecting to run a command in another container which is linked to this and should be run through php if possible.










    share|improve this question


























      0












      0








      0








      I have 2 containers up and running.



      i am logged in into one container say container A, I want to execute command x in container B from container A.



      To elaborate,



      My application has php, mysql and other tools in another container. When user clicks specific link on my php app, a specific command should run on the 3rd container.



      My first Container's Dockerfile:



      FROM php:7.1.2-apache
      RUN docker-php-ext-install mysqli

      RUN a2enmod rewrite
      RUN /etc/init.d/apache2 restart

      ADD . /var/www/html


      My second container's Dockerfile:



      FROM ubuntu:bionic
      RUN apt-get update && apt-get upgrade -y
      EXPOSE 5000



      My docker-compose.yml file is



      version: "2"

      services:
      www:
      build: .
      container_name: Web
      ports:
      - "80:80"
      restart: always
      command: tail -f /dev/null
      volumes:
      - .:/var/www/html
      - /var/run/docker.sock:/var/run/docker.sock
      networks:
      internal:
      shared:
      ipv4_address: 172.55.0.5

      ubuntu:
      build:
      context: ./dockerFiles/ubuntu
      container_name: Radius
      ports:
      - "5000:5000"
      volumes:
      - ./dockerFiles/radius/ubuntu:/ubuntu
      restart: always
      networks:
      internal:
      shared:
      ipv4_address: 172.55.0.4

      volumes:
      persistent:

      networks:
      internal:
      driver_opts:
      internal: "true"
      driver: bridge
      shared:
      driver_opts:
      enable_ipv6: "true"
      driver: bridge
      ipam:
      config:
      - subnet: 172.55.0.0/16
      gateway: 172.55.0.1




      Is this possible? If yes, can this be eloberated?



      Many Thanks in Advance



      I have tried docker-in-docker command, this doesn't seems stable and secure.



      Expecting to run a command in another container which is linked to this and should be run through php if possible.










      share|improve this question
















      I have 2 containers up and running.



      i am logged in into one container say container A, I want to execute command x in container B from container A.



      To elaborate,



      My application has php, mysql and other tools in another container. When user clicks specific link on my php app, a specific command should run on the 3rd container.



      My first Container's Dockerfile:



      FROM php:7.1.2-apache
      RUN docker-php-ext-install mysqli

      RUN a2enmod rewrite
      RUN /etc/init.d/apache2 restart

      ADD . /var/www/html


      My second container's Dockerfile:



      FROM ubuntu:bionic
      RUN apt-get update && apt-get upgrade -y
      EXPOSE 5000



      My docker-compose.yml file is



      version: "2"

      services:
      www:
      build: .
      container_name: Web
      ports:
      - "80:80"
      restart: always
      command: tail -f /dev/null
      volumes:
      - .:/var/www/html
      - /var/run/docker.sock:/var/run/docker.sock
      networks:
      internal:
      shared:
      ipv4_address: 172.55.0.5

      ubuntu:
      build:
      context: ./dockerFiles/ubuntu
      container_name: Radius
      ports:
      - "5000:5000"
      volumes:
      - ./dockerFiles/radius/ubuntu:/ubuntu
      restart: always
      networks:
      internal:
      shared:
      ipv4_address: 172.55.0.4

      volumes:
      persistent:

      networks:
      internal:
      driver_opts:
      internal: "true"
      driver: bridge
      shared:
      driver_opts:
      enable_ipv6: "true"
      driver: bridge
      ipam:
      config:
      - subnet: 172.55.0.0/16
      gateway: 172.55.0.1




      Is this possible? If yes, can this be eloberated?



      Many Thanks in Advance



      I have tried docker-in-docker command, this doesn't seems stable and secure.



      Expecting to run a command in another container which is linked to this and should be run through php if possible.







      docker docker-compose dockerfile






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 25 at 9:39







      abdul riyaz

















      asked Mar 25 at 7:33









      abdul riyazabdul riyaz

      4019




      4019






















          1 Answer
          1






          active

          oldest

          votes


















          0














          the most understandable and secure way to do this is by using the client- server pattern.



          expose a port in your 3rd container Dockerfile, and set it to execute some script on request. this container is acting as the server in this episode.



          from your php container, curl to that server every time you want the script to get executed:



          $handle = curl_init();
          curl_setopt($handle, CURLOPT_URL, $url);
          $data = curl_exec($handle);
          curl_close($handle);


          the curl should point to the 3rd container name.



          i would like to help in setting up the server-side listening on the 3rd container, just show the Dockerfile or docker-compose file it is built from.






          share|improve this answer























          • Thanks Efrat. I have edited the question and posted the docker-compose and Dockerfiles.

            – abdul riyaz
            Mar 25 at 9:38











          • making sure i got you - you want your ubuntu container to execute script on requests from www container?

            – Efrat Levitan
            Mar 25 at 9:56











          • Yep! When a request is made for example if i write function with parameter Y on php www container , that parameter is the command and should execute in ubuntu container.

            – abdul riyaz
            Mar 25 at 11:00












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55333065%2fhow-can-we-run-a-command-on-another-linked-container-from-existing-container%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          the most understandable and secure way to do this is by using the client- server pattern.



          expose a port in your 3rd container Dockerfile, and set it to execute some script on request. this container is acting as the server in this episode.



          from your php container, curl to that server every time you want the script to get executed:



          $handle = curl_init();
          curl_setopt($handle, CURLOPT_URL, $url);
          $data = curl_exec($handle);
          curl_close($handle);


          the curl should point to the 3rd container name.



          i would like to help in setting up the server-side listening on the 3rd container, just show the Dockerfile or docker-compose file it is built from.






          share|improve this answer























          • Thanks Efrat. I have edited the question and posted the docker-compose and Dockerfiles.

            – abdul riyaz
            Mar 25 at 9:38











          • making sure i got you - you want your ubuntu container to execute script on requests from www container?

            – Efrat Levitan
            Mar 25 at 9:56











          • Yep! When a request is made for example if i write function with parameter Y on php www container , that parameter is the command and should execute in ubuntu container.

            – abdul riyaz
            Mar 25 at 11:00
















          0














          the most understandable and secure way to do this is by using the client- server pattern.



          expose a port in your 3rd container Dockerfile, and set it to execute some script on request. this container is acting as the server in this episode.



          from your php container, curl to that server every time you want the script to get executed:



          $handle = curl_init();
          curl_setopt($handle, CURLOPT_URL, $url);
          $data = curl_exec($handle);
          curl_close($handle);


          the curl should point to the 3rd container name.



          i would like to help in setting up the server-side listening on the 3rd container, just show the Dockerfile or docker-compose file it is built from.






          share|improve this answer























          • Thanks Efrat. I have edited the question and posted the docker-compose and Dockerfiles.

            – abdul riyaz
            Mar 25 at 9:38











          • making sure i got you - you want your ubuntu container to execute script on requests from www container?

            – Efrat Levitan
            Mar 25 at 9:56











          • Yep! When a request is made for example if i write function with parameter Y on php www container , that parameter is the command and should execute in ubuntu container.

            – abdul riyaz
            Mar 25 at 11:00














          0












          0








          0







          the most understandable and secure way to do this is by using the client- server pattern.



          expose a port in your 3rd container Dockerfile, and set it to execute some script on request. this container is acting as the server in this episode.



          from your php container, curl to that server every time you want the script to get executed:



          $handle = curl_init();
          curl_setopt($handle, CURLOPT_URL, $url);
          $data = curl_exec($handle);
          curl_close($handle);


          the curl should point to the 3rd container name.



          i would like to help in setting up the server-side listening on the 3rd container, just show the Dockerfile or docker-compose file it is built from.






          share|improve this answer













          the most understandable and secure way to do this is by using the client- server pattern.



          expose a port in your 3rd container Dockerfile, and set it to execute some script on request. this container is acting as the server in this episode.



          from your php container, curl to that server every time you want the script to get executed:



          $handle = curl_init();
          curl_setopt($handle, CURLOPT_URL, $url);
          $data = curl_exec($handle);
          curl_close($handle);


          the curl should point to the 3rd container name.



          i would like to help in setting up the server-side listening on the 3rd container, just show the Dockerfile or docker-compose file it is built from.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 8:15









          Efrat LevitanEfrat Levitan

          1,4161317




          1,4161317












          • Thanks Efrat. I have edited the question and posted the docker-compose and Dockerfiles.

            – abdul riyaz
            Mar 25 at 9:38











          • making sure i got you - you want your ubuntu container to execute script on requests from www container?

            – Efrat Levitan
            Mar 25 at 9:56











          • Yep! When a request is made for example if i write function with parameter Y on php www container , that parameter is the command and should execute in ubuntu container.

            – abdul riyaz
            Mar 25 at 11:00


















          • Thanks Efrat. I have edited the question and posted the docker-compose and Dockerfiles.

            – abdul riyaz
            Mar 25 at 9:38











          • making sure i got you - you want your ubuntu container to execute script on requests from www container?

            – Efrat Levitan
            Mar 25 at 9:56











          • Yep! When a request is made for example if i write function with parameter Y on php www container , that parameter is the command and should execute in ubuntu container.

            – abdul riyaz
            Mar 25 at 11:00

















          Thanks Efrat. I have edited the question and posted the docker-compose and Dockerfiles.

          – abdul riyaz
          Mar 25 at 9:38





          Thanks Efrat. I have edited the question and posted the docker-compose and Dockerfiles.

          – abdul riyaz
          Mar 25 at 9:38













          making sure i got you - you want your ubuntu container to execute script on requests from www container?

          – Efrat Levitan
          Mar 25 at 9:56





          making sure i got you - you want your ubuntu container to execute script on requests from www container?

          – Efrat Levitan
          Mar 25 at 9:56













          Yep! When a request is made for example if i write function with parameter Y on php www container , that parameter is the command and should execute in ubuntu container.

          – abdul riyaz
          Mar 25 at 11:00






          Yep! When a request is made for example if i write function with parameter Y on php www container , that parameter is the command and should execute in ubuntu container.

          – abdul riyaz
          Mar 25 at 11:00




















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55333065%2fhow-can-we-run-a-command-on-another-linked-container-from-existing-container%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현