How to run 2 commands with docker exec

I need to run 2 commands with docker exec.
I am copying a file out of the docker container and don’t want to have to deal with credentials to use something like ssh.
This command copies a file:

sudo docker exec boring_hawking tar -cv /var/log/file.log | tar -x

But it creates a subdirectory var/log, I want to avoid that so if I could do these in the docker container I should be good:

  • How to solve mounting error when running docker?
  • Upgrading docker without affecting running containers
  • Making the Docker Registry HA
  • What components should be “containerized” - Docker
  • docker container port format does not looks right(like <port>-<port>)
  • Is it possible to scp/git push from my local machine to docker container hosted in AWS?
  • cd /var/log ; tar -cv ./file.log
    

    How can I make docker exec run 2 commands?

  • command not found when running in docker bash script
  • How to efficiently get info from all Docker containers running on a server via SSH?
  • Traefik accessLog configuration
  • nohup service inside docker container
  • Docker when deployed on marathon is failing continously
  • Since docker shares host kernel, why most docker images contain the kernel stuff?
  • One Solution collect form web for “How to run 2 commands with docker exec”

    This led to the answer: Escape character in Docker command line
    I ended up doing this:

    sudo docker exec boring_hawking bash -c 'cd /var/log ; tar -cv ./file.log' | tar -x
    

    So it works by, sort of, running the one bash command with a parameter that is the 2 commands I want to run.

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