Running Elixir in Docker Containers

Alvise Susmel About

December 12, 2018

X Follow Button

One of the wonderful things about Docker Containers is that you can easily freeze your environment and application in a Docker Image, and deploy it in production without worrying about installing dependencies on your servers. It just works.

This is also great for debugging. If something doesn’t work in production, you can run exactly the same image locally in matter of seconds.

The features and advantages of docker obviously don’t stop here.

In this article we see how to use Docker to run our development Elixir environment and to run multiple Elixir Nodes over a Docker bridge network.


In docker hub we find the official Elixir docker image. There are mainly two branches: the defacto image(1Gb) and the one based on alpine(80Mb) . For production I would definitively go with alpine, which is much lighter.

But, for development, the main one brings many more tools and is based on Debian stretch. The image itself is based on erlang:21 that, in turn, is based on buildpack-deps:stretch, which is Debian stretch + a collection of common build dependencies.

Dowloading the image is easy.

$ docker image pull elixir:1.7.4

Bash

Copy

Where elixir is the image (elixir in this case) and 1.7.4 (the elixir version) is the tag of the image. To check its size

$ docker image inspect elixir:1.7.4 --format '{{ .Size}}'
1072576831

Sh

Copy

To download elixir 1.7.4 based on alpine, we just need to use a different tag

$ docker image pull elixir:1.7.4-alpine
$ docker image inspect elixir:1.7.4-alpine --format '{{ .Size}}'
86796332

Bash

Copy

Both images run iex if no command is passed.

$ docker run -it elixir:1.7.4

Erlang/OTP 21 [erts-10.1.3] [source] [64-bit] [smp:6:6] [ds:6:6:10] [async-threads:1] [hipe]

Interactive Elixir (1.7.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>

Bash

Copy

We use docker run here to create a new container from the image elixir:1.7.4.

The -it option allocates a pseudo-TTY connected to the container stdin, which is what gives you interaction with the iex running in the container.

Leave the terminal with iex open and take another terminal trying this command

$ docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
bb667cecf5da        elixir              "iex"                    3 minutes ago       Up 3 minutes                            dazzling_rosalind

Bash

Copy

We see the container id and the name, dazzling_rosalind. The name, when not specified is randomly set by docker. If we quit from iex we see that the container stops.

$ docker container ls -a
...
bb667cecf5da  elixir  "iex" 12 minutes ago  Exited (0) 8 seconds ago  dazzling_rosalind

Bash

Copy

With the -a options we list all the containers, both stopped and running. Our dazzling_rosalind container stopped once we quit from iex. We can recover the same container starting it and attacching to its terminal session

$ docker container start dazzling_rosalind
dazzling_rosalind
$ docker container attach dazzling_rosalind
PRESS RETURN

iex(2)>

Bash

Copy

To stop and remove the container we just use rm with -f option, which forces the removal when the container is running.

docker container rm -f dazzling_rosalind

Bash

Copy

We can save files on a container and until this container is removed, these files are saved in its file system.

Containers should be treated as ephemeral though. It means that containers are thought to be stopped, removed and recreated without having to rely on configurations and files we save in them. To automatically remove the container when stopped we use the --rm option

$ docker container run -it --rm elixir:1.7.4

Bash

Copy

In general, when we want some files to stay persistent, we use volumes. There are different type of volumes, docker local volumes, cloud volumes connected to a docker container etc.. In this way we can destroy and recreate our containers without loosing important data.

In our case, since we want to use docker for development, the best idea to make a container see the project’s files is to use bind mounting. In this way we mount the directory of our local machine into the container filesystem. All the changes made by the container reflect in our local machine filesystem.

Bind Mounting

We use then the -v local_path:container_path option, where both paths need to be absolute. Let’s try to create a new elixir project using mix new and bind mounting a local directory.

$ docker container run --rm -v $PWD:/data -w /data elixir:1.7.4 mix new crypto
* creating README.md
* creating .formatter.exs
* creating .gitignore
* creating mix.exs
* creating config
...

$ ls -l
drwxr-xr-x  9 alvise  staff   288  8 Dec 19:54 crypto

Bash

Copy

We’ve mounted the current directory into the contasiner’s /data path, using $PWD environment variable. We’ve also added a -w /data option which tells the container to start the command into the /data working directory. We can see that the project directory crypto is now in our current directory.

Let’s move inside the crypto directory and add a dependency into mix.exs

defp deps do
  [ {:poison, "~> 4.0"} ]
end

Elixir

Copy

$ docker container run --rm -v $PWD:/app -w /app -it elixir:1.7.4 mix deps.get
Could not find Hex, which is needed to build dependency :poison
Shall I install Hex? (if running non-interactively, use "mix local.hex --force") [Yn] Y
* creating /root/.mix/archives/hex-0.18.2
...

Bash

Copy

After the dependency is downloaded and built, the container is destroyed and all the data in /root/.mix is lost. If we run again the same commands we will have again to install hex. To solve this, an similar issues, we can create a local volume

$ docker volume create elixir-mix
elixir-mix

Bash

Copy

To use it we need to add another option to the command -v volume-name:container_mount_point.

$ docker container run --rm -v elixir-mix:/root/.mix -v $PWD:/app -w /app -it  elixir:1.7.4 mix deps.get
Could not find Hex, which is needed to build dependency :poison
Shall I install Hex? (if running non-interactively, use "mix local.hex --force") [Yn] Y
* creating /root/.mix/archives/hex-0.18.2
...

$ docker container run --rm -v elixir-mix:/root/.mix -v $PWD:/app -w /app -it  elixir:1.7.4 mix deps.get
Resolving Hex dependencies...
Dependency resolution completed:
...

Bash

Copy

The first time, Hex needs to be installed. The second time the command is working properly because hex is found in the /root/.mix directory, where elixir-mix volume is mounted.

We can now run our iex loading our crypto project

$ docker container run --rm -v elixir-mix:/root/.mix -v $PWD:/app -w /app -it  elixir:1.7.4 iex -S mix
...
==> poison
Compiling 4 files (.ex)
Generated poison app
...
iex(1)> Poison.encode! %{hello: :world}
"{"hello":"world"}"

Bash

Copy

The dependencies are downloaded in deps and compiled in build project’s directory. Since these changes are reflected in our project directory via bind mounting, if we run the same command again we shouldn’t have any dependencies compilation.

Running Multiple Containers

Let’s see now how to use docker to run multiple containers in a virtual network and then run multiple Elixir Nodes.

We first need to create our bridge network, to which we will link our containers to.

$ docker network create elixir-net
$ docker network inspect elixir-net
...
"Config": [ {\
    "Subnet": "172.18.0.0/16",\
...\
```\
\
Bash\
\
Copy\
\
With `inspect` we see that our `elixir-net` network has 172.18.0.0/16 subnet.\
\
To run a container and to make it join the network we’ve just created, we use the `--network` option\
\
```bash\
$ docker run -it --rm --network elixir-net elixir:1.7.4\
iex>\
```\
\
Bash\
\
Copy\
\
Let’s use another terminal to see first the id of the container we started, and get then its IP inside _elixir-net_.\
\
```bash\
$ docker container ls\
0c219f042eb8  elixir:1.7.4  ...\
\
$ docker container inspect 0c219f042eb8 | jq\
  '.[] .NetworkSettings .Networks ."elixir-net" .IPAddress'\
"172.18.0.2"\
```\
\
Bash\
\
Copy\
\
`inspect` prints all the details of the container. With `jq` we filter them to get the IP address.\
\
Let’s run another container in the same network, starting the session in `bash` instead of iex. The main image has the `ping` command we can use to ping the other container.\
\
```bash\
$ docker run -it --rm --network elixir-net elixir:1.7.4 bash\
root@aeb8101fbb9b:/# ping 172.18.0.2\
PING 172.18.0.2 (172.18.0.2) 56(84) bytes of data.\
64 bytes from 172.18.0.2: icmp_seq=1 ttl=64 time=0.095 ms\
```\
\
Bash\
\
Copy\
\
Even if it works, we mustn’t use the IPs directly: each container has its own IP and if a container is destroyed and re-created the IP could not be the same.\
\
Hopefully we can rely on **names**. To make them work we need to start our container with the `--name` option. We also add the `-h` option to set the hostname (which will be useful later running multiple Elixir nodes).\
\
Remove first all the running containers so we can make a fresh start. Then run these two containers in two seperate terminals\
\
```bash\
# in terminal 1\
$ docker run -it --rm --network elixir-net --name elixir-1\
  -h elixir-1 elixir:1.7.4 bash\
\
root@elixir-1:/#\
\
# in terminal 2\
$ docker run -it --rm --network elixir-net --name elixir-2\
  -h elixir-2 elixir:1.7.4 bash\
\
root@elixir-2:/# ping elixir-1\
PING elixir-1 (172.18.0.2) 56(84) bytes of data.\
64 bytes from elixir-1.elixir-net (172.18.0.2): icmp_seq=1 ttl=64 ..\
```\
\
Bash\
\
Copy\
\
Now we have all we need to start iex in two separate containers and to connect the two nodes. To make them able to connect we need to use the `--sname` iex option, which assigns a short name to the node. In our case the name can be the same since we have different hostnames (`-h` option in docker).\
\
\
\
```elixir\
# Terminal 1\
$ docker run -it --rm --network elixir-net --name elixir-1\
  -h elixir-1 elixir:1.7.4 iex --sname docker\
iex(docker@elixir-1)1>\
\
# Terminal 2\
$ docker run -it --rm --network elixir-net --name elixir-2\
  -h elixir-2 elixir:1.7.4 iex --sname docker\
\
iex(docker@elixir-2)1> Node.connect :"docker@elixir-1"\
false\
```\
\
Elixir\
\
Copy\
\
And we see an error in the terminal-1\
\
```elixir\
iex(docker@elixir-1)1>\
Connection attempt from disallowed node :"docker@elixir-2"\
```\
\
Elixir\
\
Copy\
\
Something went wrong. What’s missing? The secret **cookie** needs to be the same. The best way to pass a secret in general is using environment variables. In a docker/kubernetes production environment we can safely store secrets and map them to environment variables. Right now we set the environment variable passing the plain cookie.\
\
Note we are passing `'$COOKIE'` with the quotes. doing so we avoid that our shell substitutes $COOKIE with our system $COOKIE environment variable.\
\
```elixir\
# Terminal 1\
$ docker run -it --rm -e COOKIE=secret --network elixir-net --name elixir-1\
  -h elixir-1 elixir:1.7.4 iex --sname docker --cookie '$COOKIE'\
\
# Terminal 2\
$ docker run -it --rm -e COOKIE=secret --network elixir-net --name elixir-2\
  -h elixir-2 elixir:1.7.4 iex --sname docker --cookie '$COOKIE'\
\
iex(docker@elixir-2)1> Node.connect :"docker@elixir-1"\
true\
iex(docker@elixir-2)2> Node.list\
[:"docker@elixir-1"]\
```\
\
Elixir\
\
Copy\
\
Fantastic! We can now have fun running distributed elixir code\
\
```elixir\
# Terminal 2\
iex(docker@elixir-2)3> Agent.start_link(\
    fn -> {:hello, :world} end,\
    name: {:global, MyAgent})\
{:ok, #PID<0.118.0>}\
```\
\
Elixir\
\
Copy\
\
And in the other container, in Terminal 1, we can now access to the `MyAgent` process.\
\
```elixir\
# Terminal 1\
iex(docker@elixir-1)1> Agent.get({:global, MyAgent}, fn state-> state end)\
{:hello, :world}\
```\
\
Elixir\
\
Copy\
\
## Wrap Up\
\
We saw how easy it is to use docker containers to develop and run locally our Elixir’s projects, also distributed across multiple nodes. This is just the foundation. where to start adding other services, like a [postgres](https://hub.docker.com/_/postgres/) container linked to our `elixir-net` network, so we can start working with [Ecto](https://github.com/elixir-ecto/ecto) in matter of seconds.\
\
* * *\
\
### Share this:\
\
- [Share on X (Opens in new window)X](/content/running-elixir-in-docker-containers/?share=twitter&nb=1/index.html)\
- [Share on Facebook (Opens in new window)Facebook](/content/running-elixir-in-docker-containers/?share=facebook&nb=1/index.html)\
- [Share on LinkedIn (Opens in new window)LinkedIn](/content/running-elixir-in-docker-containers/?share=linkedin&nb=1/index.html)\
- [Share on Reddit (Opens in new window)Reddit](/content/running-elixir-in-docker-containers/?share=reddit&nb=1/index.html)\
- [Email a link to a friend (Opens in new window)Email](mailto:?subject=%5BShared%20Post%5D%20Running%20Elixir%20in%20Docker%20Containers&body=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&share=email&nb=1)\
\
- [DevOps](/content/category/devops/index.html)\
- [Elixir](/content/category/elixir/index.html)\
- [New to Elixir?](/content/category/new-to-elixir/index.html)\
\
- [#docker](/content/tag/docker/index.html)\
- [#elixir](/content/tag/elixir/index.html)\
- [#otp](/content/tag/otp/index.html)\
\
Disqus Recommendations\
\
We were unable to load Disqus Recommendations. If you are a moderator please see our [troubleshooting guide](https://docs.disqus.com/help/83/).\
\
❮\
\
- 7 years ago\
- 2 comments\
\
We setup the AWS account, configure ExAws, put, list, get and delete objects. …\
\
- 7 years ago\
- 5 comments\
\
Focus on LiveView's primitives: the bricks we need to know to building a …\
\
- 7 years ago\
- 1 comment\
\
After a quick intro to containers and images, we see how easy it is to run …\
\
- 7 years ago\
- 5 comments\
\
When processing a HTTP request takes too long, Phoenix closes the …\
\
- 6 years ago\
- 6 comments\
\
Step-by-step guide how to build a polling api in Elixir and Phoenix 1.5.\
\
- 6 years ago\
- 2 comments\
\
Let's see how to use, in Phoenix LiveView, the phx-click binding along with …\
\
- 7 years ago\
- 10 comments\
\
We see how to fully implement concurrent HTTP calls, using just spawn, …\
\
- 5 years ago\
- 4 comments\
\
In this video we take a look at the Poeticoins application design, how we organize …\
\
❯\
\
tempest.services.disqus.com\
\
# tempest.services.disqus.com is blocked\
\
This page has been blocked by an extension\
\
- Try disabling your extensions.\
\
ERR\_BLOCKED\_BY\_CLIENT\
\
Reload\
\
\
This page has been blocked by an extension\
\
\
\
Disqus Comments\
\
We were unable to load Disqus. If you are a moderator please see our [troubleshooting guide](https://docs.disqus.com/help/83/).\
\
G\
\
Join the discussion…\
\
\
\
Comment\
\
###### Log in with\
\
###### or sign up with Disqus  or pick a name\
\
### Disqus is a discussion network\
\
- Don't be a jerk or do anything illegal. Everything is easier that way.\
\
[Read full terms and conditions](https://docs.disqus.com/kb/terms-and-policies/)\
\
This comment platform is hosted by Disqus, Inc. I authorize Disqus and its affiliates to:\
\
- Use, sell, and share my information to enable me to use its comment services and for marketing purposes, including cross-context behavioral advertising, as described in our [Terms of Service](https://help.disqus.com/customer/portal/articles/466260-terms-of-service) and [Privacy Policy](https://disqus.com/privacy-policy), including supplementing that information with other data about me, such as my browsing and location data.\
- Contact me or enable others to contact me by email with offers for goods or services\
- Process any sensitive personal information that I submit in a comment. See our [Privacy Policy](https://disqus.com/privacy-policy) for more information\
\
Acknowledge I am 18 or older\
\
- [Favorite this discussion](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Favorite this discussion")\
\
  - ## Discussion Favorited!\
\
\
\
    Favoriting means this is a discussion worth sharing. It gets shared to your followers' Disqus feeds, and gives the creator kudos!\
\
\
     [Find More Discussions](https://disqus.com/home/?utm_source=disqus_embed&utm_content=recommend_btn)\
\
[Share](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
  - Tweet this discussion\
  - Share this discussion on Facebook\
  - Share this discussion via email\
  - Copy link to discussion\
\
  - [Best](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
  - [Newest](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
  - [Oldest](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
- - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
  - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
  - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
C\
\
nice article, very clear for both newbies with elixir and docker, would be great a second post running phoenix with docker and maybe deploy it ;-D\
\
see more\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
- - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
  - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
  - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
S\
\
Thank you\
\
When using docker as indicated, files created with mix are root: root. If I want to keep the files owned by the current user, in the command I include --user 1000: 1000, but then mix deps.get gives error.\
\
Using 1001 as the docker group, the same error.\
\
$ docker container run -it --rm -v elixir-mix:/root/.mix --user 1000:1001 -v $PWD:/app -w /app elixir:1.7.4 bash\
\
I have no name!@elixir:/app/crypto$ mix deps.get\
\
Could not find Hex, which is needed to build dependency :poison\
\
Shall I install Hex? (if running non-interactively, use "mix local.hex --force") \[Yn\]\
\
\\*\\* (File.Error) could not make directory (with -p) "/.mix/archives/hex-0.18.2": no such file or directory\
\
(elixir) lib/file.ex:280: File.mkdir\_p!/1\
\
(mix) lib/mix/tasks/archive.install.ex:105: Mix.Tasks.Archive.Install.install/3\
\
(mix) lib/mix/local/installer.ex:107: Mix.Local.Installer.local\_install/3\
\
(mix) lib/mix/dep/loader.ex:168: Mix.Dep.Loader.with\_scm\_and\_app/4\
\
(mix) lib/mix/dep/loader.ex:121: Mix.Dep.Loader.to\_dep/3\
\
(elixir) lib/enum.ex:1314: Enum."-map/2-lists^map/1-0-"/2\
\
(mix) lib/mix/dep/loader.ex:336: Mix.Dep.Loader.mix\_children/1\
\
(mix) lib/mix/dep/loader.ex:18: Mix.Dep.Loader.children/0\
\
see more\
\
  - - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
    - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
    - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
\
\
I wouldn't change the user. Using docker for Mac, in my case, it keeps the user:group of the files.\
\
see more\
\
    - - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
      - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
      - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
S\
\
I am using Docker on Ubuntu Budgie 18.04 and files are all, even the project directory root:root.\
\
The problem appears when i want to edit files with editors on hosts, no with vi or nano in the container.\
\
see more\
\
      - - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
        - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
        - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
\
\
ah ok, that's different. Docker on linux runs natively, sharing the host kernel. In your case what I would bind mount everything, both application directory and .mix directory. It's possible to tell to mix where to store its data with MIX\_HOME env dir. I've used this command on a linux machine and seems to work:\
\
docker container run -it --rm -v $PWD:/app -w /app -e HOME=/app -e MIX\_HOME=/app/.mix --user $(id -u):$(id -g) elixir:1.7.4 bash\
\
Let me know if it works for you too and I'll update the article.\
\
see more\
\
        - - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
          - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
          - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
S\
\
santi@metabook:~/Dev/elixir$ docker container run -it --rm -e COOKIE=secret -v elixir-mix:/root/.mix -v $PWD:/app -w /app -e HOME=/app -e MIX\_HOME=/app/.mix --user $(id -u):$(id -g) --network elixir-net --name elixir -h elixir elixir:1.7.4 bash\
\
I have no name!@elixir:~$ mix new crypto\
\
\\* creating [README.md](http://disq.us/url?url=http%3A%2F%2FREADME.md%3AjjlqoEmrcirVvvdn_9lxrQyVt5s&cuid=5651236 "README.md")\
\
. . . more text . . .\
\
Run "mix help" for more commands.\
\
... \[ Now edit mix.exs on host with visual editor , without problems \]...\
\
I have no name!@elixir:~$ cd crypto/\
\
I have no name!@elixir:~/crypto$ mix deps.get\
\
Could not find Hex, which is needed to build dependency :poison\
\
. . . more text . . .\
\
I have no name!@elixir:~/crypto$\
\
\[ Every thing's OK \]\
\
Take a look a the prompt! "I have no name"!\
\
Thanks a lot!\
\
see more\
\
          - - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
            - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
            - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
\
\
Yes, that "I have no name" is pretty terrible to see...\
\
see more\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
        - - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
          - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
          - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
S\
\
One more question.\
\
¿Does I need the volume elixir-mix?\
\
I think no, cause now is on home directory.\
\
Thanks\
\
see more\
\
          - - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
            - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
            - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
\
\
correct. I was just showing the difference between a volume and bind mounting\
\
see more\
\
            - - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
              - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
              - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
S\
\
Finally I have to made a shell function to take it easy.\
\
Using $ elixdoc or $ elixdoc hostname full large command\
\
elixdoc() {\
\
HOST="${1:-\`basename $PWD\`}" && shift\
\
CMD=${@:-bash}\
\
IMAGE="elixir:1.7.4"\
\
APP=/app\
\
docker container run -it --rm \\
\
-e COOKIE=secret \\
\
-v $PWD:$APP \\
\
-w $APP \\
\
-e HOME=$APP \\
\
-e MIX\_HOME=$APP/.mix \\
\
--user $(id -u):$(id -g) \\
\
--network elixir-net \\
\
--name $HOST \\
\
-h $HOST \\
\
$IMAGE \\
\
$CMD\
\
}\
\
see more\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
- - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
  - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
  - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
J\
\
The following hangs when I try it:\
\
$ docker container start dazzling\_rosalind\
\
dazzling\_rosalind\
\
$ docker container attach dazzling\_rosalind\
\
\[hangs here\]\
\
====\
\
Edit: Okay, if I hit return while it's hanging I see:\
\
nil\
\
iex(2)>\
\
====\
\
Of course, I used the name of my container in place of dazzling\_rosalind. What terminal window do we type that into, the first one or the second one? I tried in both. Mac OSX 10.13.6 running Docker Desktop Community ( [Docker.app](http://disq.us/url?url=http%3A%2F%2FDocker.app%3Ao0xeNeDoyoyLyHPIwiOOydWB_Yw&cuid=5651236 "Docker.app")) 2.0.0.0-mac81 (29211).\
\
I read through a "Getting started with Docker (For Developers)" tutorial before reading this, and they always use \`$ docker container run ...\`. What's the advantage of using \`docker container start/attach\`?\
\
see more\
\
  - - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
    - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
    - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
\
\
Yes as you correctly said in your update, you need to press return (I've also amended the article), thanks.\
\
see more\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
  - - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
    - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
    - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
\
\
exceptionally important question - and well explained here:\
\
[https://stackoverflow.com/q...](https://stackoverflow.com/questions/34782678/difference-between-running-and-starting-a-docker-container "https://stackoverflow.com/questions/34782678/difference-between-running-and-starting-a-docker-container")\
\
see more\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
- - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
  - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
  - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
\
\
I'd certainly second that [chewM](https://disqus.com/by/chewm/ "https://disqus.com/by/chewm/") :)\
\
running Phoenix with Docker is very much doable but deploying with 'hot-reload' I am yet to see ( \*hint\* \*hint\* Alvise Susmel )\
\
;)\
\
see more\
\
  - - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
    - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
    - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
\
\
I agree with you and actually I don't see right now how we can achieve hot-reload following docker/kubernetes patterns. For sure we could run containers and loading new code when they are running, but containers (pod in kubernetes) are meant to be destroyed, recreated in another server without issues..\
\
Do you run any phoenix application in production with docker/kubernetes and that needs hot-reload?\
\
see more\
\
    - - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
      - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
      - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
\
\
no - I still learning and coming from the dark side (OO) I am yet to get fully FP'ed ;)\
\
but ultimately - yes - I will need hot-reload ( telecom-kind-of-appl ) dockers\
\
see more\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
- - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
  - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
  - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
\
\
> For production I would definitively go with alpine, which is much lighter. But, for development, the main one brings many more tools..\
\
Is it possible to use one container for development and another for production? Thanks.\
\
see more\
\
  - - [−](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Collapse")\
    - [+](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Expand")\
    - [Flag as inappropriate](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default# "Flag as inappropriate")\
\
\
\
\
Hi [Rudolf Manusadzhyan](https://disqus.com/by/rudolfmanusadzhyan/ "https://disqus.com/by/rudolfmanusadzhyan/"), you can have multiple images yes. A container is like a process, it's the execution of an image. For example, for elixir we have two images. The defacto one, which is based on debian, and the "alpine" version, which is based on the linux alpine distribution. The reason why the one based on debian is 1GB is because there is much more software and packages inside, you have the debian distribution, bash, gcc etc.. which is great for development. Once you know what you want to put in production, it's better to package your application around the alpine distribution because it's far lighter. It doesn't have bash, compilers, etc.. you just have a super minimal distribution that is focused to run elixir.\
\
see more\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
[Show more replies](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
[Load more comments](https://disqus.com/embed/comments/?base=default&f=poeticoding-blog&t_u=https%3A%2F%2Fwww.poeticoding.com%2Frunning-elixir-in-docker-containers%2F&t_d=Running%20Elixir%20in%20Docker%20Containers&t_t=Running%20Elixir%20in%20Docker%20Containers&s_o=default#)\
\
\
\
live.rezync.com\
\
# live.rezync.com is blocked\
\
This page has been blocked by an extension\
\
- Try disabling your extensions.\
\
ERR\_BLOCKED\_BY\_CLIENT\
\
Reload\
\
\
This page has been blocked by an extension\
\
\
\
pippio.com\
\
# pippio.com is blocked\
\
This page has been blocked by an extension\
\
- Try disabling your extensions.\
\
ERR\_BLOCKED\_BY\_CLIENT\
\
Reload\
\
\
This page has been blocked by an extension\
\
\
\
tempest.services.disqus.com\
\
# tempest.services.disqus.com is blocked\
\
This page has been blocked by an extension\
\
- Try disabling your extensions.\
\
ERR\_BLOCKED\_BY\_CLIENT\
\
Reload\
\
\
This page has been blocked by an extension\
\
\
\
[Elixir](/content/category/elixir/index.html)\
\
## [Nerves powered Vision – Deploy YOLOv8 on RPi5 with…](/content/nerves-powered-vision-deploy-yolov8-on-rpi5-with-hailo8l/index.html)\
\
[Alvise Susmel](/content/author/alvise/index.html)\
\
Sep 5, 202514 sec read\
\
[Elixir](/content/category/elixir/index.html)\
\
## [Building a YOLOX Plate Detector – Setup, Fine-Tuning, Metrics,…](/content/building-a-yolox-plate-detector-setup-fine-tuning-metrics-dashcam-inference/index.html)\
\
[Alvise Susmel](/content/author/alvise/index.html)\
\
Aug 29, 20253 min read\
\
[Elixir](/content/category/elixir/index.html)\
\
## [Fine-Tuning YOLO to Watch Soccer Matches](/content/fine-tuning-yolo-to-watch-soccer-matches/index.html)\
\
[Alvise Susmel](/content/author/alvise/index.html)\
\
Jul 17, 20255 min read\
\
Twitter Widget Iframe