Giter Club home page Giter Club logo

dockerize's People

Contributors

1conan avatar aacebedo avatar aegypius avatar cloverstd avatar fujiwara avatar ianneub avatar jacobmassey avatar jmcvetta avatar johnbuhay avatar jwilder avatar kaissi avatar mefellows avatar metamode avatar metmajer avatar mindaugasrukas avatar mstrzele avatar multani avatar neiljain avatar pgvishnuram avatar pukoren avatar ruudk avatar samjarrett avatar sebest avatar sjaek avatar sstarcher avatar sychan avatar testwill avatar thomasleveil avatar w4tson avatar xizhibei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dockerize's Issues

macOS release?

Can anyone point me to a pre-built macOS binary? Or tell me how to build it myself? I tried installing go via Homebrew, cloning this repo and running make but I got this error:

Building dockerize
tail.go:8:2: cannot find package "github.com/hpcloud/tail" in any of:
	/usr/local/Cellar/go/1.8.3/libexec/src/github.com/hpcloud/tail (from $GOROOT)
	/Users/tailee/go/src/github.com/hpcloud/tail (from $GOPATH)
template.go:15:2: cannot find package "github.com/jwilder/gojq" in any of:
	/usr/local/Cellar/go/1.8.3/libexec/src/github.com/jwilder/gojq (from $GOROOT)
	/Users/tailee/go/src/github.com/jwilder/gojq (from $GOPATH)
exec.go:11:2: cannot find package "golang.org/x/net/context" in any of:
	/usr/local/Cellar/go/1.8.3/libexec/src/golang.org/x/net/context (from $GOROOT)
	/Users/tailee/go/src/golang.org/x/net/context (from $GOPATH)
make: *** [dockerize] Error 1

Can not work in Alpine

Hi, I user dockerize in docker that base on alpine, I got a error prompt when I am run dockerize amd64

sh: ./dockerize: not found

But I try to compile dockerize on a container that base on alpine, it work success.

dockerize -wait: timeout after 10 seconds

Great project!

dockerize -wait really comes in handy, especially when working with docker-compose. Could you please add a --timeout option that allows users to wait for longer than only 10 seconds?

Timeout after 10s waiting on dependencies to become available: [...]

Thanks!

Add ability to wait for a file

We have a use case where a container needs to wait for a file to be generated by another container in a mounted volume (in this case it's the security config produced by pycluster) before it can start up.
It would be helpful that in addition to the tcp/http wait methods that a file method be also provided.

template error: "X" is not a method but has arguments

Sorry if this isn't the place for this.

I'm trying to make a template for nginx.conf.

nginx.tmpl has this line:
resolver {{ default .Env.RESOLVER "127.0.0.11" }};

When the container starts, this error is thrown and the container stops:

template error: template: nginx.tmpl:34:20: executing "nginx.tmpl" at <.Env.RESOLVER>: RESOLVER is not a method but has arguments

This seems almost exactly like the example, but it isn't working. Any help figuring this out would be appreciated.

Thanks.

"no command specified" on every command

running this inside an ubuntu latest image:

$ dockerize -template x:y
2015/10/22 07:13:12 no command specified
$ dockerize -stderr x
2015/10/22 07:13:50 no command specified
# this goes on for everything i do, except -version which does seem to work

any idea what is wrong? the output is really unhelpful

Add ability to wait for a file

We have a use case where a container needs to wait for a file to be generated by another container in a mounted volume (in this case it's the security config produced by pycluster) before it can start up.
It would be helpful that in addition to the tcp/http wait methods that a file method be also provided.

Logs not displayed at first start if created by child process

My container main process creates a log file during its execution. However, on first start, the file doesn't exist, so dockerize doesn't pick it up. A restart fixes the issue, but I would like dockerize to notice the file being created after the child process has started - possibly without using poll, inotify would be ideal.

Touching the log file before executing dockerize is not an option since the child process will not use it (it will create a log file with a different name).

Http waiting - specify specific URL?

I was wondering if it's possible to specify a full URL when waiting for http/https resources to come online. Our application server will return 200's on /, but I'd like to poll some resource like /sub/resource, which will return something like 404 until the application is totally loaded. Is it possible to do this with dockerize? Like:

dockerize -wait http://web:80/sub/resource

Access to JSON structures

I use dockerize with cloud foundry buildpacks. Unforunately in cloud foundry the important environment variables do contain a JSON document, so I need a way to access the values within this JSON documents.

Copy permissions from template to file

root@4a33d6ec3087:/# dockerize -template /run.sh.tmpl:/run.sh /bin/bash
root@4a33d6ec3087:/# ls -l /run.*
-rw-r--r-- 1 root root 735 Oct 14 21:05 /run.sh
-rwxr-xr-x 1 root root 777 Oct 14 21:00 /run.sh.tmpl

http wait does not work on urls with paths - works only on the hostname

dockerize -wait http://myweb:8080/some/path does not work - it seems it ignores the path and just pings the hostname on the port.

So, effectively, it only works if there is an index page setup for the web app.

The path support is needed if you want to ensure that the app started and not just initialized on the port. In my app (using spring cloud), I would prefer to wait on http://myweb:8080/health which is a sure way to know if the app has started.

Force flag is not working?

Using v0.5.0:

./dockerize -force -template test.tmpl:test [...]

The first line states:

flag provided but not defined: -force

And then it will exit with failure.

jsonQuery usage question

I'm not quite sure how to use it :/

I'm trying to build docker for nginx proxy and I could use json to define upstreams but I don't know how to build env file. At the moment I use simple --env-file for docker run but its construction doesn't allow for json - please share some light for it.

Also It would be nice to extend your - extremaly useful - script to use loops for templates.

Removed line break when replacing values?

Hi!.
We are using your project and it appears to work correctly but we have found an issue. When we try to replace 2 environment variables when we were using a template, it appears that the replacement it actually removes one line break of the file.
We have tested using a template like this:
datasource.driverClassName=org.postgresql.Driver datasource.jdbcUrl=jdbc:postgresql://{{ .Env.APP_DB_HOST }}:5432/{{ .Env.APP_DB_DATABASE }} datasource.username=xxx
That finally, and after replacing the values from the environment (and we have checked that they do not have any strange character) the result removed the line break between the 2nd and 3rd line, with this result:
datasource.driverClassName=org.postgresql.Driver datasource.jdbcUrl=jdbc:postgresql://dbhost:5432/exampledatasource.username=xxx
Best,

a 386 bin version ?

Hi,

I'm building a docker image which requires dockerize for an i386 system.

How complicated would it be to build it for i386 (I never did any golang dev). If it's easy, would you mind sharing an i386 binary ?

Thanks a lot for the help!

New release to support jsonQuery

In order to be able to use the much-needed jsonQuery function easily (we are currently just storing the binary in our own repository), we need a new release of the compiled package. Many thanks for implementing that feature!

Env vars from linked service are not resolved in Docker Compose v2

I'm using Dockerize v0.2.0 and after I switched from Docker Compose v1 to v2 I realised that environment variables from linked services are not resolved during container startup.

Dockerfile

FROM alpine:latest
......
# Install Dockerize
ENV DOCKERIZE_VERSION=0.2.0

RUN wget https://github.com/jwilder/dockerize/releases/download/v${DOCKERIZE_VERSION}/dockerize-linux-amd64-v${DOCKERIZE_VERSION}.tar.gz \
  && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-v${DOCKERIZE_VERSION}.tar.gz \
    && rm dockerize-linux-amd64-v${DOCKERIZE_VERSION}.tar.gz \
    && mkdir /etc/uchiwa

# Copy template file to image
COPY config.tmpl /etc/uchiwa/

# Run dockerize on template file and start uchiwa
CMD dockerize -template /etc/uchiwa/config.tmpl:/etc/uchiwa/config.json \
  godep go run uchiwa.go -c /etc/uchiwa/config.json

docker-compose.yml

version: '2'
services:
   sensu-api:
    build: 'sensu-api'
    environment:
      - API_PASS=slomic
      - API_USER=ismar
    links:
      - rabbitmq
      - redis
    restart: always

  uchiwa:
    build: 'uchiwa'
    environment:
      - HTTP_PASS=slomic
      - HTTP_USER=ismar
      - UCHIWA_LOG_LEVEL=warn
    links:
      - sensu-api
    ports:
      - '3000:80'
    restart: always

config.tmpl

{
    "sensu":[
        {
            "name": "{{ .Env.SENSU_NAME }}",
            "host": "{{ .Env.SENSU_API_PORT_4567_TCP_ADDR }}",
            "port": {{ .Env.SENSU_API_PORT_4567_TCP_PORT }},
            "user": "{{ .Env.SENSU_API_ENV_API_USER }}",
            "pass": "{{ .Env.SENSU_API_ENV_API_PASS }}"
        }
    ],
    "uchiwa":{
        "host": "{{ default .Env.UCHIWA_HOST "0.0.0.0" }}",
        "port": {{ default .Env.UCHIWA_PORT 80 }},
        "loglevel": "{{ default .Env.UCHIWA_LOG_LEVEL "info" }}",
        "refresh": {{ default .Env.UCHIWA_REFRESH 5 }},
        "user": "{{ .Env.HTTP_USER }}",
        "pass": "{{ .Env.HTTP_PASS }}"
    }
}

config.json (result after dockerize)

{
    "sensu":[
        {
            "name": "Sensu",
            "host": "<no value>",
            "port": <no value>,
            "user": "<no value>",
            "pass": "<no value>"
        }
    ],
    "uchiwa":{
        "host": "0.0.0.0",
        "port": 80,
        "loglevel": "warn",
        "refresh": 5,
        "user": "ismar",
        "pass": "slomic"
    }
}

When running same configuration with Docker Compose v1 I get following config.json as result:

{
    "sensu":[
        {
            "name": "Sensu",
            "host": "172.17.0.10",
            "port": 4567,
            "user": "ismar",
            "pass": "slomic"
        }
    ],
    "uchiwa":{
        "host": "0.0.0.0",
        "port": 80,
        "loglevel": "warn",
        "refresh": 5,
        "user": "ismar",
        "pass": "slomic"
    }
}

When several waits only work one

Hi, when launching dockerize with several waits it only waits for first service wanted.
#1

./dockerize -wait tcp://localhost:4444 -wait tcp://localhost:3333 -timeout 300s
2016/08/29 08:40:11 Waiting for host: localhost:4444
2016/08/29 08:40:11 Waiting for host: localhost:3333
2016/08/29 08:40:11 Problem with dial: dial tcp 127.0.0.1:3333: getsockopt: connection refused. Sleeping 5s
2016/08/29 08:40:11 Problem with dial: dial tcp 127.0.0.1:3333: getsockopt: connection refused. Sleeping 5s

Then launched nc -l 3333 and nc -l 4444 in several terminals.

But dockerized outputs:

2016/08/29 08:40:16 Connected to tcp://localhost:3333
2016/08/29 08:40:16 Problem with dial: dial tcp 127.0.0.1:3333: getsockopt: connection refused. Sleeping 5s
2016/08/29 08:40:21 Problem with dial: dial tcp 127.0.0.1:3333: getsockopt: connection refused. Sleeping 5s

I could make a workaround launching only one wait with each execution, like this:

./dockerize -wait tcp://localhost:3333 && ./dockerize -wait tcp://localhost:4444 -timeout 300s

Log files not empty after forwarding to stderr/stdout

Log lines is forwarded to stdout, it's ok.
But docker containers is continue growing, because log files are not cleaned after forwarding each line to stderr/stdout.
It would be good, if dockerize clean forwarded lines from log files.

It isn't possible to tail a named pipe

If you try to tail a named pipe:

% mkfifo /tmp/fifo
% cat <<EOF > /tmp/test.sh
#!/bin/bash

echo "this is going to the fifo" > /tmp/fifo
sleep 5
echo "from exec stdout"
EOF
% chmod +x /tmp/test.sh
% dockerize --stdout /tmp/fifo /tmp/test.sh
from exec stdout
2017/12/14 14:02:32 Command finished successfully.

Nothing is printed coming from the named pipe in question.

DNS issue when using Docker 1.13 and Compose 1.10

Hi there,

I have an issue when waiting for other containers using dockerize (tested both 0.2.0 and 0.3.0): Using Docker 1.12, I could wait for a different container to become available using the service name from the compose file. In Docker 1.13/Compose 1.10 this does not seem to work anymore. dockerize tries to use the external DNS server for some reason, and will not resolve the internal DNS names which Compose applies to the containers.

Has anybody seen this as well? Is there a workaround?

New release?

Thanks for this great project! I just wanted to ask when you'll release a new version of it, since there we're numerous commits since 0.2.0.

Can't execute dockerize binary: No such file or directory

After the last update of a dockerize base image my containers that depends on dockerize all failed with bash: /usr/local/bin/dockerize: No such file or directory error. Although dockerize is in its place inside container and /usr/local/bin/ in PATH.

For example, following Dockerfile brings this issue.

FROM jwilder/dockerize AS dockerize
FROM nginx

COPY --from=dockerize /usr/local/bin/dockerize /usr/local/bin/dockerize
COPY ./nginx.conf /etc/nginx/nginx.conf

ENTRYPOINT [ "dockerize", "-template", "/etc/nginx/nginx.conf:/etc/nginx/nginx.conf" ]
CMD nginx

Does anyone meet this issue?

By the way, it would be great to tag images that are available on dockerhub, because for now there is no way to roll back to previous stable version – there is only :latest build.

Pegging CPU on stat file

Hi,

We are running dockerize (as an entry to a docker container) on CoreOS running docker 1.10.

$ ps -L -p $(pgrep dockerize) -o pid,ppid,lwp,nlwp,osz,rss,ruser,pcpu,stime,etime,args
  PID  PPID   LWP NLWP SZ   RSS RUSER    %CPU STIME     ELAPSED COMMAND
27808 27778 27808   15  -  4436 root     19.0 Jan27 55-11:40:36 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778 27826   15  -  4436 root      0.0 Jan27 55-11:40:35 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778 27827   15  -  4436 root      0.0 Jan27 55-11:40:35 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778 27828   15  -  4436 root      0.0 Jan27 55-11:40:35 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778 27829   15  -  4436 root      0.0 Jan27 55-11:40:35 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778 27831   15  -  4436 root     18.3 Jan27 55-11:40:35 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778 27834   15  -  4436 root     19.0 Jan27 55-11:40:35 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778 28014   15  -  4436 root     21.0 Jan27 55-11:40:34 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778 28015   15  -  4436 root     19.2 Jan27 55-11:40:34 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778  3846   15  -  4436 root     20.0 Jan27 55-11:38:45 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778 21550   15  -  4436 root     19.3 Jan27 55-10:52:50 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778 21551   15  -  4436 root     18.8 Jan27 55-10:52:50 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778 21552   15  -  4436 root     17.6 Jan27 55-10:52:50 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778 21224   15  -  4436 root     17.6 Jan27 54-16:26:46 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
27808 27778  4406   15  -  4436 root     19.3 Feb27 23-23:06:26 dockerize -poll -stdout /var/log/myapp/erlang.log.1 -stdout /var/log/myapp/report.log -stdout /var/log/myapp/run_erl.log myapp start-nodetach
$ ls -al report.log run_erl.log erlang.log.1 
-rw-r--r--. 1 myappuser myappuser 99972 Feb 17 14:49 erlang.log.1
-rw-r--r--. 1 myappuser myappuser  5333 Jan 27 00:16 report.log
-rw-r--r--. 1 myappuser myappuser  1063 Jan 27 00:14 run_erl.log
$ stat report.log run_erl.log erlang.log.1 
  File: `report.log'
  Size: 5333            Blocks: 16         IO Block: 4096   regular file
Device: ca10h/51728d    Inode: 8528997     Links: 1
Access: (0644/-rw-r--r--)  Uid: (  499/myappuser)   Gid: (  499/myappuser)
Access: 2017-01-27 00:14:29.485589340 +0000
Modify: 2017-01-27 00:16:18.130206016 +0000
Change: 2017-01-27 00:16:18.130206016 +0000
  File: `run_erl.log'
  Size: 1063            Blocks: 8          IO Block: 4096   regular file
Device: ca10h/51728d    Inode: 8528981     Links: 1
Access: (0644/-rw-r--r--)  Uid: (  499/myappuser)   Gid: (  499/myappuser)
Access: 2017-01-27 00:14:28.411622249 +0000
Modify: 2017-01-27 00:14:28.411622249 +0000
Change: 2017-01-27 00:14:28.411622249 +0000
  File: `erlang.log.1'
  Size: 99972           Blocks: 208        IO Block: 4096   regular file
Device: ca10h/51728d    Inode: 8528980     Links: 1
Access: (0644/-rw-r--r--)  Uid: (  499/myappuser)   Gid: (  499/myappuser)
Access: 2017-01-27 00:14:28.411622249 +0000
Modify: 2017-02-17 14:49:23.220633374 +0000
Change: 2017-02-17 14:49:23.220633374 +0000

None of the files changed for a while, but I can see some calls being repeated a lot.
Interestingly enough it's only running stat on one file /var/log/myapp/run_erl.log

28014 12:30:46 <... futex resumed> )    = 1
28014 12:30:46 stat("/var/log/myapp/run_erl.log",  <unfinished ...>
28014 12:30:46 <... stat resumed> {st_mode=S_IFREG|0644, st_size=1063, ...}) = 0
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC,  <unfinished ...>
28014 12:30:46 <... clock_gettime resumed> {4797503, 437654662}) = 0
28014 12:30:46 futex(0xc82005f310, FUTEX_WAKE, 1 <unfinished ...>
28014 12:30:46 <... futex resumed> )    = 1
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC,  <unfinished ...>
28014 12:30:46 <... clock_gettime resumed> {4797503, 437784081}) = 0
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC,  <unfinished ...>
28014 12:30:46 <... clock_gettime resumed> {4797503, 437847955}) = 0
28014 12:30:46 futex(0x94e878, FUTEX_WAIT, 0, {0, 249870581} <unfinished ...>
28014 12:30:46 <... futex resumed> )    = -1 ETIMEDOUT (Connection timed out)
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC,  <unfinished ...>
28014 12:30:46 <... clock_gettime resumed> {4797503, 688008797}) = 0
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC,  <unfinished ...>
28014 12:30:46 <... clock_gettime resumed> {4797503, 688114082}) = 0
28014 12:30:46 futex(0xc82005f310, FUTEX_WAKE, 1 <unfinished ...>
28014 12:30:46 <... futex resumed> )    = 1
28014 12:30:46 stat("/var/log/myapp/run_erl.log",  <unfinished ...>
28014 12:30:46 <... stat resumed> {st_mode=S_IFREG|0644, st_size=1063, ...}) = 0
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC,  <unfinished ...>
28014 12:30:46 <... clock_gettime resumed> {4797503, 688445606}) = 0
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC,  <unfinished ...>
28014 12:30:46 <... clock_gettime resumed> {4797503, 688540383}) = 0
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC,  <unfinished ...>
28014 12:30:46 <... clock_gettime resumed> {4797503, 688634838}) = 0
28014 12:30:46 futex(0x94e878, FUTEX_WAIT, 0, {0, 249905223} <unfinished ...>
28014 12:30:46 <... futex resumed> )    = -1 ETIMEDOUT (Connection timed out)
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC, {4797503, 938844516}) = 0
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC, {4797503, 938921901}) = 0
28014 12:30:46 futex(0xc82005f310, FUTEX_WAKE, 1 <unfinished ...>
28014 12:30:46 <... futex resumed> )    = 1
28014 12:30:46 stat("/var/log/myapp/run_erl.log", {st_mode=S_IFREG|0644, st_size=1063, ...}) = 0
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC, {4797503, 939242099}) = 0
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC,  <unfinished ...>
28014 12:30:46 <... clock_gettime resumed> {4797503, 939333317}) = 0
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC,  <unfinished ...>
28014 12:30:46 <... clock_gettime resumed> {4797503, 939461107}) = 0
28014 12:30:46 futex(0x94e878, FUTEX_WAIT, 0, {0, 249908782} <unfinished ...>
28014 12:30:46 <... futex resumed> )    = -1 ETIMEDOUT (Connection timed out)
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC, {4797504, 189643569}) = 0
28014 12:30:46 clock_gettime(CLOCK_MONOTONIC, {4797504, 189728813}) = 0
28014 12:30:46 futex(0xc82005f310, FUTEX_WAKE, 1 <unfinished ...>
28014 12:30:46 <... futex resumed> )    = 1
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 86.51   53.965961          39   1374870    267375 futex
 13.40    8.361000         504     16597           select
  0.08    0.047012           0    850030           sched_yield
  0.00    0.002000        2000         1         1 restart_syscall
  0.00    0.001560           0     36611           clock_gettime
  0.00    0.000174           0       680           stat
  0.00    0.000000           0         1           madvise
------ ----------- ----------- --------- --------- ----------------
100.00   62.377707               2278790    267376 total

There should be stat calls for the other 2 files but they don't appear.

No resolution of network hostname in Docker Beta

When I have a compose file (version 2), that uses the default Docker networking and defines a service of db and app, I can ping db from the app container, but when I do dockerize -wait tcp://db:5432, it never finds it. Pinging reveals that db gets translated to something like server_db_1.server_default. Using that hostname works with dockerize. Is this a Docker Networking or Docker Beta issue?

Incorrect documentation for timeout

Docs provide this example for the option timeout:

dockerize -wait tcp://db:5432 -wait http://web:80 -timeout 10

But it doesn't since the timeout is not in the correct format. A correct version would be:

dockerize -wait tcp://db:5432 -wait http://web:80 -timeout 10s

Lookup ENV var from string?

Is it possible to look up an env var using a string? Example:

{{ .Env["FOO"] }}

Instead of

{{ .Env.FOO

Extra to this, is it possible to define an array of strings and loop through them?

Signals not handled properly

Running supervisord within dockerize I've noticed the following issues:

When dockerize receives SIGINT (e.g. ctrl-c in an interactive docker container) the following happens:

  • dockerize outputs Received signal: interrupt
  • dockerize forwards this signal to its child process (supervisord in my case)
  • supervisord gracefully terminates its "programs" and exits
  • dockerize outputs Command finished successfully.
  • (so far so good, now for the unexpected)
  • dockerize doesn't exit
  • after 10 seconds, dockerize outputs Killing command due to timeout. and exits

Seems to me the 10 second wait has no function, the child process is already gone (which dockerize noticed) and dockerize should exit right away.

Another issue occurs when dockerize receives SIGTERM (e.g. on docker stop):

  • dockerize exits immediately without any output
  • signal is not forwarded to child process (supervisord) and not waited on
  • supervisord (and its running "programs") don't get a chance to gracefully shutdown
  • actually the child process (supervisord and its children) is not killed at all and keeps running; however, the container is destroyed along with any processes in it, similar to a SIGKILL to those processes (unclean shutdown)

In contrast, when supervisord receives SIGTERM, it forwards this to its running programs and waits for them to exit cleanly, killing them with SIGKILL if it takes too long. IMO dockerize should do something similar.

Allow -wait value to be templated

It would be useful to be able to use go templates when specifying the host we want to wait for. Especially since the hostname/port could be provided by the environment.

here's an example of what it would look like for a user of dockerize

FROM alpine

ADD output/dockerize /bin/dockerize
ENTRYPOINT ["dockerize", "-wait", "{{ .Env.SERVICE_ADDR }}"]
CMD ["myscript.sh"]

Expanding list of helper functions

@jwilder Dockerize is fantastic. I've started using it, and it's helping to fill big configuration holes that Docker has.

What do you think about expanding the list of helper functions available? Your docker-gen project has a lot of good functions that you make available to templates, but it's a little sparse in Dockerize. One that simple addition would be the strings.Join method. A common pattern I find myself using is a comma separated list of host:port entries -e 1.1.1.1:80,2.2.2.2:81 that needs to be translated to "1.1.1.1:80","2.2.2.2:81" in the template file.

Will you accept pull requests for new functions, or is there an underlying anti-pattern you are trying to avoid? (bloat, dependency requirements, redundancy, etc.)

Pegging one CPU

When I run the -stdout on OSX virtualbox, it pegs one cpu.

Dockerize and sub process exit codes

Howdy,

I think dockerize fills a need that I've had over and over with docker-ized apps. Thanks!

  1. Currently dockerize will never exit if the sub process exits with 0.

  2. Also, if the sub process exits with anything other than 0, dockerize will exit, but it will exit with 1.

Would you accept a PR that would change the behavior to the following?

  1. If the sub process exits 0, then dockerize should exit 0.

  2. If the sub process exits n, then dockerize should exit n also.

Add ability to tail log files using a glob pattern

I'd like the ability to tail a bunch of logs using a glob pattern. Dockerize should monitor the filesystem in some way to find new files to tail based on the glob pattern.

@jwilder If you are ok with this functionality then I'd be happy to tackle it.

Cannot chain commands with &&

I'm running postgraphql which doesn't have a nice way to send it to the background.

I want to dockerize two commands: pg-migrator and postgraphql

If I do:

command: dockerize -wait tcp://db:5432 pg-migrator postgres://db
command: dockerize -wait tcp://db:5432 postgraphql --watch

then the postgraphql command happens before the pg-migrator and the pg-migrator never runs. If I reverse the order, then postgraphql runs first and pg-migrator never runs. If I try and chain the commands using pg-migrator postgres://db && postgraphql --watch then the pg-migrator command gets the entire string as command-line arguments and errors out because it's expecting a version number or nothing, and ofcourse postgraphql never runs.

Ideally, when && is present, the two commands would be run in sequence.

panic on program exit

when the program run by dockerize exits, dockerize panics with a deadlock.

fatal error: all goroutines are asleep - deadlock!

goroutine 16 [semacquire, 35 minutes]:
sync.runtime_Semacquire(0xc208034298)
/usr/local/go/src/pkg/runtime/sema.goc:199 +0x30
sync.(*WaitGroup).Wait(0x651980)
/usr/local/go/src/pkg/sync/waitgroup.go:129 +0x14b
main.main()
/home/jwilder/go/src/github.com/jwilder/dockerize/dockerize.go:93 +0x983

goroutine 19 [finalizer wait, 37 minutes]:
runtime.park(0x415720, 0x6511d0, 0x64fd29)
/usr/local/go/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x6511d0, 0x64fd29)
/usr/local/go/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
/usr/local/go/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1445

Runtime error after first run

I'm trying to test dockerise using the nginx example, but when my container runs

ADD nginx.conf.tmpl /etc/nginx/nginx.conf.tmpl #my test tmpl, which doesn't use any 
CMD dockerize -template /etc/nginx/nginx.conf.tmpl:/etc/nginx/sites-available/default -stdout /var/log/nginx/access.log -stderr /var/log/nginx/error.log nginx

I get this scary stacktrace:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x403566]

goroutine 9 [running]:
main.tailFile(0x7fa0318de540, 0xc82004a340, 0x7ffc2a7adf0c, 0x18, 0xc820026018)
        /Users/jason/go/src/github.com/jwilder/dockerize/tail.go:34 +0x4f6
created by main.main
        /Users/jason/go/src/github.com/jwilder/dockerize/dockerize.go:131 +0xb83

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0x6de90c)
        /usr/local/go/src/runtime/sema.go:43 +0x26
sync.(*WaitGroup).Wait(0x6de900)
        /usr/local/go/src/sync/waitgroup.go:126 +0xb4
main.main()
        /Users/jason/go/src/github.com/jwilder/dockerize/dockerize.go:134 +0xbb2

goroutine 5 [syscall]:
os/signal.loop()
        /usr/local/go/src/os/signal/signal_unix.go:22 +0x18
created by os/signal.init.1
        /usr/local/go/src/os/signal/signal_unix.go:28 +0x37

goroutine 7 [runnable]:
os/exec.(*Cmd).Start(0xc8200a0000, 0x0, 0x0)
        /usr/local/go/src/os/exec/exec.go:318 +0xb01
main.runCmd(0x7fa0318de540, 0xc82004a340, 0xc82000e4b0, 0x7ffc2a7adf25, 0x5, 0xc82000a1f0, 0x0, 0x0)
        /Users/jason/go/src/github.com/jwilder/dockerize/exec.go:23 +0x1d5
created by main.main
        /Users/jason/go/src/github.com/jwilder/dockerize/dockerize.go:121 +0x986

goroutine 8 [runnable]:
github.com/hpcloud/tail/watch.(*InotifyTracker).NewWatcher(0xc8200b2000, 0x0, 0x0, 0x0)
        /Users/jason/go/src/github.com/hpcloud/tail/watch/inotify_tracker.go:27 +0xe0
github.com/hpcloud/tail.TailFile(0x7ffc2a7adeea, 0x19, 0x0, 0x1, 0x0, 0x1, 0x0, 0xc8200101e0, 0x0, 0x0, ...)
        /Users/jason/go/src/github.com/hpcloud/tail/tail.go:106 +0x5af
main.tailFile(0x7fa0318de540, 0xc82004a340, 0x7ffc2a7adeea, 0x19, 0xc820026010)
        /Users/jason/go/src/github.com/jwilder/dockerize/tail.go:19 +0x123
created by main.main
        /Users/jason/go/src/github.com/jwilder/dockerize/dockerize.go:126 +0xa75

goroutine 10 [runnable]:
gopkg.in/fsnotify%2ev0.(*Watcher).readEvents(0xc820014360)
        ?:0
created by gopkg.in/fsnotify%2ev0.NewWatcher
        ?:0 +0x40b

goroutine 11 [runnable]:
gopkg.in/fsnotify%2ev0.(*Watcher).purgeEvents(0xc820014360)
        /Users/jason/go/src/gopkg.in/fsnotify.v0/fsnotify.go:20
created by gopkg.in/fsnotify%2ev0.NewWatcher
        ?:0 +0x42d

goroutine 17 [runnable]:
gopkg.in/fsnotify%2ev0.(*Watcher).readEvents(0xc8200ac180)
        ?:0
created by gopkg.in/fsnotify%2ev0.NewWatcher
        ?:0 +0x40b

goroutine 18 [runnable]:
gopkg.in/fsnotify%2ev0.(*Watcher).purgeEvents(0xc8200ac180)
        /Users/jason/go/src/gopkg.in/fsnotify.v0/fsnotify.go:20
created by gopkg.in/fsnotify%2ev0.NewWatcher
        ?:0 +0x42d

can this be run with alpine-node?

Alpine-node is great in its compactness but it doesn't use libc and has some other variations. Just wondering if this great container might be available in this flavour of Linux.

Question about wait

Hello,

Thanks for this tool. I wanted to use it in our environment, but unfortunatelly I can't use it how I wanted.
I want a container to wait while a https site is available.
I thought that if I type ./dockerize -wait https://github.com:443, dockerize will wait while the page is available and try to reach it in every second or 2 seconds or similar intervall till timeout.
But dockerize try it only once and exit when timeout exceeds. Is it the expected behaviour ? Or I missed something ?

Thanks in advance

Can I set interval for `-wait`?

Hello,

Is it possible to set an interval so that dockerize -wait would make requests less frequently? I have a service that has an expensive status check. dockerize is spamming the status endpoint, significantly slowing down the startup process. I would like to query the service less frequently, for example every five seconds:

$ dockerize -wait http://web:80/status -interval 5s -timeout 120s

Thanks! ✌️

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.