title: Docker Cannot link to a non running container
body: <p>I need to create Rails and Mysql containers with docker-compose. When I try to create links between containers with <code>docker-compose up</code>, I get</p>
  
  <blockquote>
    <p>Cannot start container
    9b271c58cf6aecaf017dadaf5b Cannot link to a non running container:
    /puma_db_1 AS /puma_web_1/db</p>
  </blockquote>
  
  <p>Files</p>
  
  <p><strong>Dockerfile</strong></p>
  
  <pre><code>FROM ubuntu:14.04
  
  RUN apt-get -y update
  RUN apt-get -y install git curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
  
  RUN apt-get -y install libmysqlclient-dev
  RUN git clone https://github.com/sstephenson/rbenv.git /root/.rbenv
  RUN git clone https://github.com/sstephenson/ruby-build.git /root/.rbenv/plugins/ruby-build
  RUN echo 'eval "$(rbenv init -)"' &gt;&gt; $HOME/.profile
  RUN echo 'eval "$(rbenv init -)"' &gt;&gt; $HOME/.bashrc
  
  RUN rbenv install 2.1.5
  RUN rbenv global 2.1.5
  RUN gem install rails -v 4.0.11
  
  ADD app.tar.gz /home/
  WORKDIR /home/app
  
  RUN bundle install
  EXPOSE 3000
  CMD ["rails", "server", "-b", "0.0.0.0"]
  </code></pre>
  
  <p><strong>docker-compose.yml</strong></p>
  
  <pre><code>db:  
    image: mysql:latest
    environment:
      MYSQL_DATABASE: app_development
      MYSQL_USER: mysql
      DATABASE_PASSWORD: onetwo
      ROOT_PASSWORD: onetwo
  web:
    build: .
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    ports:
      - "4000:3000"
    links:
      - db
  </code></pre>