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.

  • How to map a virtual host to a container in docker?
  • How to make docker containers host-agnostic
  • Is there anyway to start rsyslogd without sudo access?
  • Containers - What are their benefits, if they can't run across platform
  • Ubuntu based docker-machine image
  • (mac) dockers , commit changes in mongo doesn't work
  • 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.

  • Private Github repositories in dockerized rails application during build
  • Cannot mount volume in docker
  • Launching jobs with large docker images in mesos via aurora can be slow
  • How to manage environment variables in Rancher
  • docker compose: rebuild of one linked container breaks nginx's upstream
  • Docker attach delay
  • 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.