Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker will not attach to an image

I have a fig.yml file that I am using to set up my docker containers. I run this by typing ./fig up Then it outputs the following:

Recreating docker_memcache_1...
Recreating docker_sphinx_1...
Recreating docker_percona_1...
Recreating docker_php_1...
Recreating docker_sa_1...
Attaching to docker_memcache_1, docker_percona_1, docker_php_1

So once that is done everything is up and running. My issue is that for some reason it is not attaching to the nginx container I have set up. The docker ps command outputs the following:

9bb0c647338e        php:latest          "/usr/sbin/php-fpm -   2 minutes ago       Up 2 minutes        9000/tcp            docker_php_1        
9f74789bdb15        percona:latest      "mysqld"               3 minutes ago       Up 3 minutes                            docker_percona_1    
b848d3442bdf        memcached:latest    "/bin/sh -c memcache   3 minutes ago       Up 3 minutes        11211/tcp           docker_memcache_1  

So the memcache image, the php image, and the percona image all are good to go, however there is no nginx docker image like there should be.

Below is how I have my fig.yml file set up, which is basically the file that launches everything. Does anyone have any ideas on what may be happening? Just to note i do have the daemon set to off so it should not be quitting automatically.

fig.yml File here :

sa:
  image: nginx
  links:
    - php:php-fpm
  volumes:
    - ./svn (path here)
    - ./cert:/(path here)
  ports:
    - "8080:80"
memcache:
  image: memcached
  hostname: memcached.docker
sphinx:
  image: sphinx
  hostname: sphinx.docker
percona:
  image: percona
  hostname: percona.docker
php:
  image: php
  hostname: php.docker
  links:  
    - memcache:memcache.docker
    - sphinx:sphinx.docker
    - percona:percona.docker

Also thought I would include my nginx Dockerfile in case there is something in there im missing Any help is greatly appreciated

Nginx Dockerfile

From centos:6.6
RUN yum -y install http://mirror.us.leaseweb.net/epel/6/i386/epel-release-6-8.noarch.rpm
RUN yum -y install nginx && rm /etc/nginx/conf.d/*
CMD ["nginx", "-g", "daemon off;"]
EXPOSE 80 443
COPY sa.conf /etc/nginx/conf.d/
COPY base /etc/nginx/base/
like image 271
Johnathon22 Avatar asked Oct 20 '22 16:10

Johnathon22


1 Answers

Run docker ps -a to show all containers, not just running containers. You'll see docker_sa_1 listed as a stopped container. This is because it crashed immediately on start-up. Unfortunately, fig doesn't show the logs for you (or shut down the stack automatically) when this happens.

Run docker logs docker_sa_1 to see the output. Hopefully, there will be a nice Nginx error message for you. If you can't find anything, then remove the sa entry from your fig.yml, do a fig up to get everything else started, then run

docker run -it --link=docker_php_1:php-fpm -v $PWD/svn:(?) -v $PWD/cert:(?) -p 8080:80 nginx

(You'll need to fill in the ?s with the path bits you left out) This is equivalent to what Fig's doing, except we're starting the container interactive with an attached tty instead of attaching later. If you still can't get any error messages, run

docker run -it --link=docker_php_1:php-fpm -v $PWD/svn:(?) -v $PWD/cert:(?) -p 8080:80 nginx /bin/bash

to get a live shell on the container. Then try starting Nginx yourself and dig for log files after it crashes.

like image 68
Nathaniel Waisbrot Avatar answered Oct 22 '22 23:10

Nathaniel Waisbrot