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 use --volume option with Docker Toolbox on Windows?
  • What does Docker add to lxc-tools (the userspace LXC tools)?
  • Two containers - two Pythons - one site-packages?
  • Dockerizing npm & bower install using the digitallyseamless/nodejs-bower-grunt docker image
  • RabbitMQ cluster by docker-compose on different hosts and different projects
  • How can I configure an index pattern?
  • cd /var/log ; tar -cv ./file.log
    

    How can I make docker exec run 2 commands?

  • How add file in volume for docker image from docker-machine on linux host
  • Host to container volume mapping using Ansible not working
  • Is it possible to run docker services in dockerfile based on some conditions?
  • what are the pros and cons of creating kafka broker and zookeeper in two docker conatiners in same machine
  • Sharing namespaces within Docker
  • Is it possible to prevent RedHat/CentOS Docker host root access from within a container?
  • 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.