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:

  • ASP.NET docker image exposed ports are closed
  • Docker containers clustering
  • Docker: How to re-create dockers additional iptables rules?
  • How to enable secure communication between Docker Containers in a Swarm?
  • Variable substitution in docker-compose.yml file when running docker-compose with sudo
  • Docker - push from dockerhub to trusted registry?
  • cd /var/log ; tar -cv ./file.log

    How can I make docker exec run 2 commands?

  • Container NAMES when deploying with Docker
  • How to create User/Database in script for Docker Postgres
  • NodeJS + Mysql with Docker Compose 2
  • Dockerfile runs on Mac but won't run on Linux behind my proxy
  • Docker behind proxy that changes ssl certificate
  • Zypper repository authentication (non-interactive)
  • 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.