In some cases you may need to send data from your Docker containers to your local machine. This could be for sending data to a local webserver or something else entirely, but as it isn’t something that Docker directly supports, we need a bit of a workaraound to achieve it. Luckily, this is why this gist exists. No need to scour the web for hours and contemplate your existance in search for a solution, i’ve already done that part for you!
So there are two ways of achieving this, depending on if you’re running Ubuntu or macOS, as Docker runs inside of a VM on macOS.
- On Ubuntu:
- Add the following alias to your
.bashrc
(or whatever shell you’re using):