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:

  • Docker Daemon stop - Timeout for container defaults 10s
  • How can I rate limit network traffic on a docker container
  • How to get the ip address of the docker host (which will be used in containers) from the host itself
  • Sprockets::FileNotFound in Projects#index
  • Backslash preservation with Docker, echo, and Perl
  • Is it possible to view docker-compose logs in the output window running in Windows?
  • cd /var/log ; tar -cv ./file.log

    How can I make docker exec run 2 commands?

  • Dockerfile and background running mysql server
  • Can Terraform set a variable from a remote_exec command?
  • SIGTERM not received by java process using 'docker stop' and the official java image
  • why shipyard docker container does not start?
  • How to get all Travis CI environment variables, excluding the default system ones?
  • Docker History Base Image Add:sha256hash
  • 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.