Executing docker command from a remote machine

I have a requirement where I need to execute some docker commands from a remote machine.

I am using java ssh library to connect to the machine where I need to execute the docker commands, and then trying to execute the command.

  • Slow performance on Docker Containers as a Compile and Run Sandbox
  • Tomcat's Spring app properties with docker container linking
  • How can i keep crontab in file in ubuntu docker
  • Getting a “A blocking operation was interrupted by a call to WSACancelBlockingCall” error when consuming Shipyard API using RestSharp
  • Script test to see if a tool is already loaded?
  • How to pass an environment variable into a RUN command
  • The actual docker command is:

    docker exec -it idaas_webtier_1 /bin/bash
    _tadm1="${OTD_HOME}/bin/tadm"
    _tadm2="--user=${OTD_ADMIN_USER} --password-file=${OTD_ADMIN_PWD} --host=${HOSTNAME} --port=${OTD_ADMIN_PORT} --no-prompt --accept-cert"
    $_tadm1 pull-config $_tadm2 --config=${OTD_CONFIG_NAME} ${HOSTNAME}
    $_tadm1 create-origin-server-pool $_tadm2 --type=http --config=${OTD_CONFIG_NAME} --origin-server=server.us.oracle.com:7001 qaverify-server-pool
    $_tadm1 set-health-check-prop $_tadm2 --config=${OTD_CONFIG_NAME} --origin-server-pool=qaverify-server-pool request-method=GET request-uri=/
    $_tadm1  create-route $_tadm2 --config=${OTD_CONFIG_NAME} --vs=${OTD_CONFIG_NAME} --origin-server-pool=qaverify-server-pool --condition="\$uri=~\"/testApp.*\"" qaverify-route
    $_tadm1 deploy-config $_tadm2 --restart ${OTD_CONFIG_NAME}
    exit
    

    When trying remotely, I added the actual values for the variables and put it in a shell script and executing the sh script, but it executes only the first line
    The script is as below

    docker exec -it idaas_webtier_1 /bin/bash
    _tadm1=/scratch/oracle/otd/bin/tadm
    _tadm2="--user=admin --password-file=/scratch/oracle/otd/password-file --host=admin-server.cloudgate.dev.oraclecloud.local --port=8989 --no-prompt --accept-cert"
    $_tadm1 pull-config $_tadm2 --config=idcs-config admin-server.cloudgate.dev.oraclecloud.local
    $_tadm1 create-origin-server-pool $_tadm2 --type=http --config=idcs-config --origin-server=adc6260266.us.oracle.com:7001 qaverify-server-pool
    $_tadm1 set-health-check-prop $_tadm2 --config=idcs-config --origin-server-pool=qaverify-server-pool request-method=GET request-uri=/
    $_tadm1  create-route $_tadm2 --config=idcs-config --vs=idcs-config --origin-server-pool=qaverify-server-pool --condition="\$uri=~\"/testApp.*\"" qaverify-route
    $_tadm1 deploy-config $_tadm2 --restart idcs-config
    exit
    

    It executes only the first line and not the rest.

    If I add '|' to the commands as:

    docker exec -it idaas_webtier_1 /bin/bash | _tadm1=/scratch/oracle/otd/bin/tadm
    

    It says:

    _tadm1=/scratch/oracle/otd/bin/tadm: Command not found.

    Any pointer on this would help.

  • Autoscale Docker Swarm Services
  • Docker routing/reverse proxy issue, can't curl other container
  • Can't get MLT Framework to process audio in Docker container
  • Docker Compose Shared Folder
  • docker: 'stack' is not a docker command
  • Spark standalone cluster on docker in network “bridge”
  • One Solution collect form web for “Executing docker command from a remote machine”

    U could write a shell script and directly run the script instead of accessing the bash terminal.
    Eg.,
    docker exec -it idaas_webtier_1 tadm.sh

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.