Giter Site home page Giter Site logo

bibendi / dip Goto Github PK

View Code? Open in Web Editor NEW
1.2K 16.0 42.0 574 KB

The dip is a CLI dev–tool that provides native-like interaction with a Dockerized application.

License: MIT License

Shell 0.16% Ruby 99.84%
docker docker-compose cli gem ruby zsh bash thor

dip's People

Contributors

alexskr avatar artofhuman avatar bibendi avatar br3nt avatar d-lebed avatar deniskorobicyn avatar dependabot-preview[bot] avatar depfu[bot] avatar dmitrybochkarev avatar dsalahutdinov avatar isqad avatar leipeleon avatar nilcolor avatar omarsotillo avatar palkan avatar tmimura39 avatar toshimaru avatar ujihisa avatar willtcarey avatar zaratan avatar zavan 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

dip's Issues

Run command with env variable

For example in case below BUNDLE_VERSION in command is empty

# dip.yml

environment:
   BUNDLE_VERSION: 1.12.5

interaction:
  rspec:
    service: app
    command: bundle exec appraisal bundle _${BUNDLE_VERSION}_ exec rspec

Support `.yaml`

Describe the bug
Currently only .yml is supported, e.g. dip.yml and not dip.yaml.

To Reproduce

  1. Install Dip
  2. Use any dip.yaml configuration, including the default but renamed to dip.yml.
For completeness here is the configuration explicitly
$ dip ls
ERROR: Could not find dip.yml config

With the following

file: dip.yaml

version: '6.0.0'

environment:
  RAILS_ENV: development

compose:
  files:
    - docker-compose.yml
  project_name: higher

interaction:
  sh:
    description: Open a Bash shell within a Rails container (with dependencies up)
    service: runner
    command: /bin/bash

  bash:
    description: Run an arbitrary script within a container (or open a shell without deps)
    service: runner
    command: /bin/bash
    compose_run_options: [no-deps]

  bundle:
    description: Run Bundler commands
    service: runner
    command: bundle
    compose_run_options: [no-deps]

  rake:
    description: Run Rake commands
    service: runner
    command: bundle exec rake

  rails:
    description: Run Rails commands
    service: runner
    command: bundle exec rails
    subcommands:
      s:
        description: Run Rails server available at http://localhost:3030
        service: rails
        compose:
          run_options: [service-ports, use-aliases]

  yarn:
    description: Run Yarn commands
    service: runner
    command: yarn
    compose_run_options: [no-deps]

  rspec:
    description: Run Rails tests
    service: runner
    environment:
      RAILS_ENV: test
    command: bundle exec rspec

  rubocop:
    description: Run Rubocop
    service: runner
    command: bundle exec rubocop
    compose_run_options: [no-deps]

  psql:
    description: Run psql console
    service: postgres
    command: psql -h postgres -U postgres -d example_app_dev

  'redis-cli':
    description: Run Redis console
    service: redis
    command: redis-cli -h redis

provision:
  - dip compose down --volumes
  - dip compose up -d postgres redis
  - dip bundle install
  - dip yarn install
  - dip rails db:setup

The exact same file as dip.yaml

$ dip ls
sh         # Open a Bash shell within a Rails container (with dependencies up)
bash       # Run an arbitrary script within a container (or open a shell without deps)
bundle     # Run Bundler commands
rake       # Run Rake commands
rails      # Run Rails commands
rails s    # Run Rails server available at http://localhost:3030
yarn       # Run Yarn commands
rspec      # Run Rails tests
rubocop    # Run Rubocop
psql       # Run psql console
redis-cli  # Run Redis console

Expected behavior
Works as it would if said config file was named dip.yml.

Context (please complete the following information):

  • OS: 5.7.12-arch1-1
  • Version: 6.0.0

Additional context
Add any other context about the problem here.

port forwardings in docker-compose.yml are not activated via dip

Describe the bug

I found the following difference in the behaviors between docker-compose and dip.

  • 1: normal docker-compose command:
    • PORTS: 0.0.0.0:3000->3000/tcp, 0.0.0.0:9229->9229/tcp
  • 2: dip command
    • PORTS: (empty)

To Reproduce
Steps to reproduce the behavior:

  1. Check https://github.com/hachi8833/dip_issue and README to reproduce the issue

Expected behavior

I expect that dip activates the port forwarding configs in docker-compose.yml.
I need to specify the explicit HOST env as 0.0.0.0 to expose the port for nuxt-app, but this can't be used via dip.

Screenshots

image

image

Context (please complete the following information):

  • OS: macOS Big Sur (11.6)
  • Docker Desktop 4.2.0 (70708)
  • dip: 7.2.0
  • Ruby: ruby 3.0.3p157

(I'm wondering if I took a mistake or something...)

Best regards,

Only string env vars supports

Hello

napolskih$ git diff dip.yml
-  DOCKER_RUBY_VERSION: '2.3'
+  DOCKER_RUBY_VERSION: 2.3

napolskih$ dip version
Unhandled exception: Expected String, not 2.3 at line 5, column 24 (YAML::ParseException)
  from YAML::Nodes::Scalar@YAML::Nodes::Node#raise<String>:NoReturn
  from String::new<YAML::ParseContext, YAML::Nodes::Node+>:String
  from Dip::Config#initialize<YAML::ParseContext, YAML::Nodes::Node+, Nil>:(Array(String) | Nil)
  from Dip::config:Dip::Config
  from Dip::env:Dip::Environment
  from __crystal_main
  from main

napolskih$ git diff dip.yml

napolskih$ dip version
2.2.1

Chaining commands doesn't work anymore

Describe the bug

The fix for #113 broke our own dip.ymls with no beautiful way to fix it.

We have many command chains in them like command: nvm use 12 && nvm run test. Since #113, the second part of the command will be executed on the host and not inside the container. Also note that it also breaks any backtick ` as the command will be ran on the host.

To Reproduce

entrypoint.sh:

#!/bin/bash
set -e

echo "$@"
eval "$@"

Dockerfile:

FROM ruby:2.7
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]

docker-compose.yml

version: '3.7'
services:
  app:
    build: .

dip.yml

version: "6"

compose:
  files:
    - docker-compose.yml

interaction:
  test_chain:
    service: app
    command: pwd && bash -c 'pwd'
  test_backquote:
    service: app
    command: echo `pwd`

All output are created with DIP_ENV=debug

With dip 6.1.0 (expected behaviour)

  • dip test_chain
[{}, "docker", ["inspect", "--format", "{{ .NetworkSettings.Networks.frontend.IPAddress }}", "dnsdock"]]
[{"DIP_DNS"=>"127.0.0.11"}, "docker-compose", ["--file", "/Users/pasind/tmp/test_dip/docker-compose.yml", "run", "--rm", "app", "pwd", "&&", "bash", "-c", "pwd"]]
Creating test_dip_app_run ... done
pwd && bash -c pwd
/
/
  • dip test_backquote
[{}, "docker", ["inspect", "--format", "{{ .NetworkSettings.Networks.frontend.IPAddress }}", "dnsdock"]]
[{"DIP_DNS"=>"127.0.0.11"}, "docker-compose", ["--file", "/Users/pasind/tmp/test_dip/docker-compose.yml", "run", "--rm", "app", "echo", "`pwd`"]]
Creating test_dip_app_run ... done
echo `pwd`
/

With dip 7.0.1 (new behaviour)

  • dip test_chain
[{}, "docker inspect --format '{{ .NetworkSettings.Networks.frontend.IPAddress }}' dnsdock"]
[{"DIP_DNS"=>"127.0.0.11"}, "docker-compose --file /Users/pasind/tmp/test_dip/docker-compose.yml run --rm app pwd && bash -c 'pwd'"]
Creating test_dip_app_run ... done
pwd
/
/Users/pasind/tmp/test_dip
  • dip test_backquote
[{}, "docker inspect --format '{{ .NetworkSettings.Networks.frontend.IPAddress }}' dnsdock"]
[{"DIP_DNS"=>"127.0.0.11"}, "docker-compose --file /Users/pasind/tmp/test_dip/docker-compose.yml run --rm app echo `pwd`"]
Creating test_dip_app_run ... done
echo /Users/pasind/tmp/test_dip
/Users/pasind/tmp/test_dip

Context

  • OS: MacOS
  • Version <7 and 7+

Workaround and proposed solution

There's a workaround that works for us but makes the dip.yml quite ugly. We could wrap any command in '''original command''' or "'original command'". This work around works both in 6.1 and 7.0.

The solutions I can see are:

  • Providing an option for a command: in the dip.yml, for an interaction specifying safe: true will automatically wrap the command in quotes.
  • Automatically detect if there's a , a ||or a&&` in the command and then automatically wrapping.
  • Always wrap
  • Instead of wrapping we could also use the old code/behaviour.

In any case, if we can find a solution that works for everyone I will gladly make the PR for this.

Don't use run vars when run containers in the up mode

DIP_ENV=debug BOOTSNAP=0 rails s

[{"RAILS_ENV"=>"development", "DISABLE_SPRING"=>"1", "DIP_DNS"=>"127.0.0.11"}, "docker-compose", ["--file", "docker-compose.yml", "up", "-e", "BOOTSNAP=0", "web"]]

-e is an illegal argument for docker-compose up.

question regarding description string

I'd like to have my description strings be able to access environment variables.
I'd also like to be able to set my other variables, like my database name.

Use case. In my dip.yml file I set a variable that compose uses, which works fine, but I'd like to be able to have the string printed with dip ls reflect that port number, and I'd like to pass in the db name to the pgsql service:

environment:     
  RAILS_ENV: development             
  EXPOSED_RAILS_PORT: 3004
  DB_NAME:my_db
<snip> 
subcommands:
      s:
        description: Run Rails server available at http://localhost:${EXPOSED_RAILS_PORT}
        service: rails
        compose:
          run_options: [service-ports, use-aliases]

  psql:
    description: Run psql console
    service: postgres
    # Because this is a rails project, the name of the database
    # (project_dev) is set in config/database.yml
    # command: env PGPASSWORD=postgres psql -h postgres -U postgres -d project_dev
    command: env PGPASSWORD=postgres psql -h postgres -U postgres -d ${DB_NAME}

This doesn't work now, I believe because the variables set under environment are only used as pass throughs to docker-compose. It would be great if I could access them in my description strings though.
Any thoughts?

dip provision fails if there is a space in the path name

Describe the bug
When there is a space in the path to the current working folder, dip provision fails.

To Reproduce
Steps to reproduce the behaviour:

  1. Create a folder /tmp/Test Projects/project1.
  2. Create a basic dip.yml in the folder:
version: '4.1'

compose:
  files:
    - docker-compose.yml
  project_name: test

provision:
  - dip compose down
  - dip compose up -d
  1. Create a basic docker-compose.yml in the folder:
version: '3.5'

services:
  test:
    image: alpine
    command: tail -f /dev/null
  1. Run dip provision from the folder.

Expected behaviour
The container is provisioned without error.

Actual behaviour
The following error is emitted:

No such command: Projects/project1/docker_compose.yml

Screenshots
If applicable, add screenshots to help explain your problem.

Context (please complete the following information):

  • OS: macOS 10.14.6 (18G9028)
  • Version: 6.0.0

Additional context
The error is doubly confusing as the file specified is docker-compose.yml, with a hyphen, and yet the error message mentions docker_compose.yml with an underscore.

Compose "files" yml value is ignored in dip.override.yml files

Describe the bug

compose:
  files:

Is ignored in dip.override.yml files

Steps to reproduce
Steps to reproduce the behavior:

  1. Create a dip.yml in a parent folder
  2. In a subfolder, create a functional docker-compose.yml, docker-compose-dev.yml, and a dip.override.yml with these contents:
# Required minimum dip version
version: '7.0'

environment:
  COMPOSE_EXT: dev

compose:
  files:
    - docker-compose.yml
    - docker-compose.$COMPOSE_EXT.yml
  1. Run dip compose up from the subfolder
  2. Only the docker-compose.yml file is used in the docker-compose call

Expected behavior
All files listed under the compose files yml key are used in the docker-compose call

Context (please complete the following information):

  • OS: Mac OS 11.2
  • Version 7.1

Environment variables from .env not loaded when using dip in a sub-directory

This is more a question than a bug report.

I am using DIP version 5.0.0 with the precompiled binary on Linux x86_64.
I have the following project :

dip/
├── subdir/
├── .env
├── dip.yml
└── docker-compose.yml
#.env
TAG=latest
# docker-compose.yml
version: '3.7'

services:

  alpine:
    image: alpine:$TAG
# dip.yml
version: '5.0.0'

interaction:
  test:
    service: alpine
    command: echo 'test succeeded'

When I use dip from the root directory (where docker-compose.yml and dip.yml files are located) this is works as expected, but I when I use it from subdir/ I get the following error :

$ dip test
WARNING: The TAG variable is not set. Defaulting to a blank string.
ERROR: no such image: alpine:: invalid reference format

I know this is the default behaviour of docker-compose which looks for a .env file only in the current working directory. But as a CLI tool, I want to use dip in various sub-directories.

Is there any way to do this ? Am I doing something wrong ?

`dip nginx` Default Image Change to `nginxproxy/nginx-proxy`

The default Image for $ dip nginx is https://github.com/bibendi/nginx-proxy

method_option :image, aliases: "-i", type: :string, default: "bibendi/nginx-proxy:latest",

But, this Image has not been maintained for a long time!

Currently, using this Image generates a malformed /etc/nginx/conf.d/default.conf and nginx -s reload fails.
We have not been able to determine the cause of the failure, but have confirmed that using the original Image, https://github.com/nginx-proxy/nginx-proxy, eliminates this problem.

Since https://github.com/nginx-proxy/nginx-proxy seems to be actively maintained, why not change it to use this Image by default?

I am aware that it is possible to change the Image used with the --image option, but I am hoping to change the default Image as I have had difficulty identifying where the problem is originating.

each_with_object' for nil:NilClass raised when `interaction` config key is missing

When running the command dip ls, an NoMethodError is raised when the interaction config key is missing from dip.yml:

"undefined method `each_with_object' for nil:NilClass (NoMethodError)"

Steps to reproduce the behavior:

  1. Provide dip.yml config
version: '5'

compose:
  files:
    - docker-compose.yml
  1. Provide docker-compose.yml
version: '3.7'

services:
  app:
      build:
        context: .
        dockerfile: Dockerfile
  1. Run command

dip ls

  1. See error
Traceback (most recent call last):
	12: from /Users/br3nt/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `<main>'
	11: from /Users/br3nt/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `eval'
	10: from /Users/br3nt/.rvm/gems/ruby-2.6.3/bin/dip:23:in `<main>'
	 9: from /Users/br3nt/.rvm/gems/ruby-2.6.3/bin/dip:23:in `load'
	 8: from /Users/br3nt/.rvm/gems/ruby-2.6.3/gems/dip-5.0.0/exe/dip:23:in `<top (required)>'
	 7: from /Users/br3nt/.rvm/gems/ruby-2.6.3/gems/dip-5.0.0/lib/dip/cli.rb:31:in `start'
	 6: from /Users/br3nt/.rvm/gems/ruby-2.6.3/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
	 5: from /Users/br3nt/.rvm/gems/ruby-2.6.3/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
	 4: from /Users/br3nt/.rvm/gems/ruby-2.6.3/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
	 3: from /Users/br3nt/.rvm/gems/ruby-2.6.3/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
	 2: from /Users/br3nt/.rvm/gems/ruby-2.6.3/gems/dip-5.0.0/lib/dip/cli.rb:47:in `ls'
	 1: from /Users/br3nt/.rvm/gems/ruby-2.6.3/gems/dip-5.0.0/lib/dip/commands/list.rb:10:in `execute'
/Users/br3nt/.rvm/gems/ruby-2.6.3/gems/dip-5.0.0/lib/dip/interaction_tree.rb:35:in `list': undefined method `each_with_object' for nil:NilClass (NoMethodError)

Expected behavior

It would be nice a message was displayed letting me know I was missing a required config key.

Rails logger, bybug

Hi!

Awesome project! Trying to set it up on my rails 6 app. Everything works fine except when I try to debug with byebug or pry and when I try to write something to the logs ex; puts "lol" * 100 nothing happens.

Am I missing some configuration steps to make this work?

Thanks

dip fails with psych 4.0.0

Describe the bug

dip fails with the breaking changes in the newer psych 4.0.0 gem:

ruby/psych#487

To Reproduce
Steps to reproduce the behavior:

  1. gem update psych
  2. run any dip commands such as dip ls.
  3. dip fails.
$ dip sh
/Users/<username>/.config/anyenv/envs/rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/psych-4.0.0/lib/psych.rb:322:in `safe_load': wrong number of arguments (given 4, expected 1) (ArgumentError)
	from /Users/<username>/.config/anyenv/envs/rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/dip-7.1.0/lib/dip/config.rb:65:in `load_yaml'
	from /Users/<username>/.config/anyenv/envs/rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/dip-7.1.0/lib/dip/config.rb:107:in `config'
	from /Users/<username>/.config/anyenv/envs/rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/dip-7.1.0/lib/dip/config.rb:90:in `block (2 levels) in <class:Config>'
	from /Users/<username>/.config/anyenv/envs/rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/dip-7.1.0/lib/dip/cli.rb:27:in `start'
	from /Users/<username>/.config/anyenv/envs/rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/dip-7.1.0/exe/dip:23:in `<top (required)>'
	from /Users/<username>/.anyenv/envs/rbenv/versions/3.0.1/bin/dip:23:in `load'
	from /Users/<username>/.anyenv/envs/rbenv/versions/3.0.1/bin/dip:23:in `<main>'

The symptom is not related with the configs in dip.yml or docker-compose.yml.

Expected behavior

Any dip commands should work with psych 4.0.0.

Actually, just running gem uninstall psych resolves the issue because psych 3.3.0 is a "default gem" in the current Ruby 3.0.1p64.

$ gem uninstall psych
$ gem list|grep psych
psych (default: 3.3.0)

Context (please complete the following information):

  • OS: macOS Big Sur 11.3.1
  • Ruby version: 3.0.1p64
  • Dip Version 7.1.0

Additional context

I guess there might occur some more fixes or changes regarding psych breaking changes. The situation might be in fluid.

https://bugs.ruby-lang.org/issues/17866

Rails has also been affected by the changes in psych:

rails/rails#42249

Allow to run app with port mapping

For example, I have compose file:

› cat docker-compose.yml
version: '2'

services:
  web:
    build: '.'
    command: 'bash -c "bundle exec hanami server -p 3000 --host 0.0.0.0"'
    environment:
      - SSH_AUTH_SOCK=/ssh/auth/sock
    ports:
      - '3000:3000'
    volumes:
      - '.:/app'
      - ssh-data:/ssh:ro
    depends_on:
      - db

and dip.yml

...

  hanami:
    service: web

    subcommands:
      server:
        service: web

If i run server through dip:
DIP_DEBUG=1 dip hanami server

"docker-compose --file docker-compose.yml --project-name auto run -e HANAMI_ENV=development --rm web"
b1596b2a4c43        auto                            "bash -c 'bundle exec"   2 days ago          Up 2 seconds        3000/tcp                     auto_web_run_1

Port mapping not work.
For simple applications which don't use dns we should allow run app server with port mapping.
compose command should be with --service-ports

docker-compose --file docker-compose.yml --project-name auto run -e HANAMI_ENV=development --service-ports --rm web
4c90c609da55        auto                            "bash -c 'bundle exec"   2 days ago          Up 4 seconds        0.0.0.0:3000->3000/tcp       auto_web_run_1

maybe we should use special option in dip.yml ports: true?

hanami
  service: web
  
   subcommands:
     server:
       service: web
       ports: true

What do u think?

ssh add on 0.7.0

This release broke it -

$ dip ssh add
ssh_data
Conflicting options: --rm and -d

compose_run_options: [rm] ???

Is it possible to have containers started via dip, remove themselves once they're finished with?

If I understand docker(-compose) well enough, then I'm thinking something like the --rm flag.

I guessed it might be possible to configure via the dip.yml file, something like:

compose_run_options: [rm]

But this doesn't work

Thanks.

Command Interpolation Enhancements

2 Enhancement Requests:

  1. Do not replace non-environment variables in provisioning commands.
    For example, in this dip.yml: The first provision command outputs:

    [email protected]:organization/repo.git [email protected]:organization/repo2.git
    repo name:
    repo name:
    

    I've debugged it quite thoroughly and it seems that the interpolation step here and subsequently here replaces all variables with their corresponding environment variable first from the yml, then the environment if it exists, else it gets replaced with a blank string (hence why $REPOS is correctly replaced, but $repo is blank). This should instead only replace the variable if an environment variable has been explicitly declared.

    This would allow one to offload a good bit of setup logic into dip's provisioning functionality. I have this dip.yml at the root of my projects, and a simple dip provision could bring everything up for me without having to create a bunch of shell scripts, if this were to work.

  2. Allow generalized, folder-specific command aliases
    One of my favorite features of dip is its ability to dynamically alias commands when a dip.yml file is found. I'd like to be able to add additional aliases that do not reference a specific docker-compose service. In the example above, you can see I've stubbed out what I'd imagine it to look something like under "interaction". Currently running this command results in a lib/dip/interaction_tree.rb:61:in 'fetch': key not found: :service error since the service key is not found.

    I would love to be able to use dip for all my project-specific aliases, and not just docker-compose ones (the goal is for it to feel native, right? 💯 ). If this were to work, I could run a simple dip start to bring up both nginx and dns, as well as anything else necessary for the environment to function!

P.S. While I'm not a Ruby dev, I'm loving dip so far. It's encapsulated a lot of my ideal workflow and tooling when working in a multi-project Docker environment. Great work on this! I'm hoping to be able to adopt this or a flavor of it into our company's workflow. I'd love to see some more documentation around the capabilities of it if you ever find the time!

environment configuration is not working

Version: 3.8.2 (MacOS binary).

Environment variables specified under interaction -> [service] -> environment are not passed to container.

Example:

interaction:
  service: app
  environment:
    SAMPLE: 42
  command: echo

Expected:

$ dip echo $SAMPLE
42

Actual:

$ dip echo $SAMPLE

Feature request: Make it easier to bootstrap a new project with dip install

Describe the bug
Not really a bug, more of a feature request

Allow dip to dip install the newest files needed for dip to run and manage itself:

A simpler way of kicking of dip in a new project as I caught myself setting up a new project via:

  • cp -r ../some-other-project/.dockerdev .
  • cp ../some-other-project/dip.yml .
  • cp ../some-other-project/docker-compose.yml .

To Reproduce
Steps to reproduce the behavior:

  1. Provide dip.yml config
  2. Provide docker-compose.yml
  3. Run command
  4. See error

Expected behavior
dip install

gives me

  • .dockerdev folder
  • docker-compose.yml the latest and greatest version
  • dip.yml the latest and greatest

Screenshots
If applicable, add screenshots to help explain your problem.

Context (please complete the following information):

  • OS: [e.g. Ubuntu 18.04.3]
  • Version [e.g. binary 4.3.2]

Additional context
I agree this has some RTFM to it, as I would be able to start from the latest and greatest by searching around a little, but still, I think this would make for a great extension of an already great 🚀 gem.

Run/exec performance

Thanks for Dip. Saved me having to customise various plug-ins to wrap Docker Compose commands.

Does Dip run a new container each time? If so, is it possible to run a new container if doesn't exist and then exec afterwards to boost performance?

Command Not Found

I tried to install precompiled binary in Arch Linux system:
What i did:

❯ sudo su                                                                                                           
alexey-pc# curl -L https://github.com/bibendi/dip/releases/download/3.8.3/dip-`uname -s`-`uname -m` > /usr/local/bin/dip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100     9    0     9    0     0      7      0 --:--:--  0:00:01 --:--:--     7
alexey-pc# exit
❯ sudo chmod +x /usr/local/bin/dip

What I have:

❯ dip --help
/usr/local/bin/dip: line 1: Not: command not found

Could I do something wrong?

How do I restart just the rails app?

I don't want to stop the posgres and such, just want to kick the rails process.

The rails service has a dependency on postgres so that adds a layer of complexity as well.

Thanks.

Since 7.1.2 `shell: false` commands with any argument fails with "undefined local variable or method `default_args' "

Describe the bug
Since 7.1.2 (It works with 7.1.1) if a command is declared as shell: false it will fail if given any argument.

Here is the stacktrace:

Traceback (most recent call last):
        9: from /Users/pasind/.rvm/gems/ruby-2.7.4@shotgun/gems/dip-7.1.2/exe/dip:23:in `<main>'
        8: from /Users/pasind/.rvm/gems/ruby-2.7.4@shotgun/gems/dip-7.1.2/lib/dip/cli.rb:31:in `start'
        7: from /Users/pasind/.rvm/gems/ruby-2.7.4@shotgun/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
        6: from /Users/pasind/.rvm/gems/ruby-2.7.4@shotgun/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        5: from /Users/pasind/.rvm/gems/ruby-2.7.4@shotgun/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        4: from /Users/pasind/.rvm/gems/ruby-2.7.4@shotgun/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        3: from /Users/pasind/.rvm/gems/ruby-2.7.4@shotgun/gems/dip-7.1.2/lib/dip/cli.rb:85:in `run'
        2: from /Users/pasind/.rvm/gems/ruby-2.7.4@shotgun/gems/dip-7.1.2/lib/dip/commands/run.rb:30:in `execute'
        1: from /Users/pasind/.rvm/gems/ruby-2.7.4@shotgun/gems/dip-7.1.2/lib/dip/commands/run.rb:59:in `compose_arguments'
/Users/pasind/.rvm/gems/ruby-2.7.4@shotgun/gems/dip-7.1.2/lib/dip/commands/run.rb:84:in `get_args': undefined local variable or method `default_args' for #<Dip::Commands::Run:0x00007f939d82d628> (NameError)

To Reproduce
Steps to reproduce the behavior:

  1. Provide dip.yml config
compose:
  files:
    - ./docker-compose.yml
interaction:
  rvm:
    description: Start rvm in the app container
    service: app_dev
    command: rvm
    shell: false
  1. Provide docker-compose.yml
    Not really relevant. I can provide one if needed.

  2. Run command
    dip rvm install 2.7.4

  3. See error

Expected behavior
Should work.

Screenshots
Capture d’écran 2021-07-14 à 09 45 51
The second dip command is using 7.1.1

Context (please complete the following information):

  • OS: OSX 14
  • Version 7.1.2

Question: Are you able to interpolate env variables or command in compose_run_options?

Hi,

Was wondering if it would be possible to interpolate $(pwd), ${DIP_WORK_DIR_REL_PATH} or other env, commands inside compose_run_options. Below an example why that would be useful:

We have scripts that we need to run for our dev env that developers don't really need to understand (other members of the team not knowledgeable about the tech). One example here is that we need to add a script to a container temporarily (not defined as a volume in the docker-compose) for the duration of the script. We can use the -v (https://docs.docker.com/compose/reference/run/) for mounting a volume with docker-compose but that only works if you give it an absolute path. It cannot work with relatives paths and we are trying todo the following.

truncate for clarity

  vault_setup:
    description: Setup the vault
    service: vault
    command: /bin/sh
    compose_run_options:
      [
        no-deps,
        use-aliases,
        "-e VAULT_ADDR=https://host.docker.internal:8200",
        "-e VAULT_SKIP_VERIFY=true",
        "-v ${DIP_WORK_DIR_REL_PATH}/vault/init.file:/vault/init.file:ro"
     ]

what does work if we provide it the full path: (but that is hard to spread across the team cause those paths are not going to be the same)

  vault_setup:
    description: Setup the vault
    service: vault
    command: /bin/sh
    compose_run_options:
      [
        no-deps,
        use-aliases,
        "-e VAULT_ADDR=https://host.docker.internal:8200",
        "-e VAULT_SKIP_VERIFY=true",
        "-v /Users/some_path/vault/init.file:/vault/init.file:ro"
      ]

So is there a way that you think off that would allow use to interpolate something in the run_options?

Question: How to customize resolver IP?

The doc uses 127.0.0.1 for *.docker.

# Create resolver
```sh
sudo touch /etc/resolver/docker
echo "nameserver 127.0.0.1" | sudo tee -a /etc/resolver/docker
```
# Dnsmasq
```sh
brew install dnsmasq
echo 'address=/docker/127.0.0.1' >> $(brew --prefix)/etc/dnsmasq.conf
brew services restart dnsmasq
```

Background: I have valet (think puma-dev for php) installed which occupies 127.0.0.1. Following the steps in the docs, my dip-rails.docker resolved to valet.

Tried to use 127.0.123.1 and 172.17.0.1(as in https://github.com/aacebedo/dnsdock/blob/1b558dc15527c149fc540f8934116e7791a8b994/readme.md#L291-L294). dip-rails.docker failed to resolve to docker in both cases (ERR_NAME_NOT_RESOLVED).

Question: How to customize resolver IP?

Thanks!!!

Question: How can I provide arguments to `dip compose`?

Hey all,

First, thank you for building this helpful tool that makes my life a bit easier. Second, my apologies for asking this question as Github issue - I didn't know if I should go pester people on Twitter or not 😄 .

I'd like to automatically provide arguments to dip compose - specifically, I'd like to have the flags set true for Docker's buildkit commands: COMPOSE_DOCKER_CLI_BUILD=1 and DOCKER_BUILDKIT=1. That way, whenever I run dip compose build, it will automatically add DOCKER_BUILDKIT=1.

Thanks for any and all help.

Unable to use nginx proxy

First and foremost, thanks for the great tool. It makes working with docker so much more enjoyable.

Describe the bug
I attempt to use dip nginx up along with setting the VIRTUAL_HOST, VIRTUAL_PATH, and VIRTUAL_PORT environment variables on the rails service. I also added the networks as shown in the example for the frontend and default networks. Whenever I try to connect to the hostname I used it doesn't seem to work. I either get a 503 Service Temporarily Unavailable response from nginx. The logs show the request if I do curl -H "Host: companycam.local" localhost but it doesn't actually send it to my app.

To Reproduce
Steps to reproduce the behavior:

  1. Provide dip.yml config
version: "4.1"

environment:
  RAILS_ENV: development

compose:
  files:
    - docker-compose.yml
  project_name: companycam

interaction:
  sh:
    description: Open a Bash shell within a Rails container (with dependencies up)
    service: runner
    command: /bin/bash

  bash:
    description: Open a Bash shell
    service: runner
    command: /bin/bash
    compose_run_options: [no-deps]

  guard:
    description: Run guard
    service: runner
    environment:
      RAILS_ENV: test
      KMS_KEY_ID: insecure-test-key
      GENIUS_SCAN_KEY: test-key
    command: bundle exec guard

  bundle:
    description: Run Bundler commands
    service: runner
    command: bundle

  yarn:
    description: Run Yarn commands
    service: runner
    command: yarn

  rake:
    description: Run Rake commands
    service: runner
    command: bundle exec rake

  rails:
    description: Run Rails commands
    service: runner
    command: bundle exec rails
    subcommands:
      s:
        description: Run Rails server available at http://localhost:3000
        service: rails
        compose:
          run_options: [service-ports, use-aliases]

  sidekiq:
    description: Run Sidekiq worker
    service: runner
    command: bundle exec sidekiq

  rspec:
    description: Run RSpec commands within test environment
    service: runner
    environment:
      RAILS_ENV: test
      KMS_KEY_ID: insecure-test-key
      GENIUS_SCAN_KEY: test-key
    command: bundle exec rspec

  rubocop:
    description: Lint ruby files
    service: runner
    command: bundle exec rubocop
    compose:
      run_options: [no-deps]

  dev_prime:
    description: Setup the local databases with some default data
    service: runner
    command: bundle exec rails dev:prime

  psql:
    description: Open a Postgres console
    service: postgis
    default_args: companycam_development
    command: psql -h postgis -U postgres

  mongo:
    description: Open a Mongo console
    service: mongo
    command: mongo --host mongodb://mongo:27017/companycam_development

provision:
  - dip compose down --volumes --remove-orphans
  - dip compose up -d
  - dip bundle install
  - dip yarn install
  - dip rails db:create
  - dip rails db:environment:set RAILS_ENV=${RAILS_ENV}
  - dip rails db:schema:load
  - dip rails db:migrate
  - dip rails db:create_indexes
  1. Provide docker-compose.yml
version: "2.4"

x-app: &app
  build:
    context: .dockerdev
    dockerfile: Dockerfile
    args:
      RUBY_VERSION: "2.5.7"
      PG_MAJOR: "10"
      NODE_MAJOR: "10"
      YARN_VERSION: "1.22.5"
      BUNDLER_VERSION: "2.1.4"
  volumes:
    - .:/app:cached
    - bundle:/bundle
  environment: &env
    NODE_ENV: development
    RAILS_ENV: ${RAILS_ENV:-development}
    NPM_TOKEN: "${NPM_TOKEN}"
    BUNDLER_VERSION: "2.1.4"
  image: companycam-dev:0.0.1
  tmpfs:
    - /tmp

x-backend: &backend
  <<: *app
  stdin_open: true
  tty: true
  volumes:
    - .:/app:cached
    - rails_cache:/app/tmp/cache
    - bundle:/bundle
    - node_modules:/app/node_modules
    - packs:/app/public/packs
    - .dockerdev/.psqlrc:/root/.psqlrc:ro
  environment:
    <<: *env
    BOOTSNAP_CACHE_DIR: /bundle/bootsnap
    WEBPACKER_DEV_SERVER_HOST: webpacker
    MALLOC_ARENA_MAX: 2
    WEB_CONCURRENCY: ${WEB_CONCURRENCY:-2}
    HISTFILE: /app/log/.bash_history
    PSQL_HISTFILE: /app/log/.psql_history
    EDITOR: vim
    REDIS_URL: redis://redis:6379/0
    KMS_KEY_ID: ${KMS_KEY_ID}
    SIDEKIQ_REDIS_URL: redis://redis:6379/1
    REDIS_OBJECTS_URL: redis://redis:6379/2
    SEARCHKICK_REDIS_URL: redis://redis:6379/3
    RACK_THROTTLE_REDIS_URL: redis://redis:6379/4
    GRAPHQL_REDIS_URL: redis://redis:6379/5
    DATABASE_URL: postgres://postgres:postgres@postgis:5432/companycam_${RAILS_ENV:-development}
    EVENTS_DATABASE_URL: postgres://postgres:postgres@postgis:5432/events_${RAILS_ENV:-development}
    MONGO_URL: "mongodb://mongo:27017/companycam_${RAILS_ENV:-development}"
    ELASTICSEARCH_URL: http://elasticsearch:9200
    VIRTUAL_HOST: '*.companycam.local'
    VIRTUAL_PATH: '/'
    VIRTUAL_PORT: '3000'
  depends_on:
    postgis:
      condition: service_healthy
    redis:
      condition: service_started
    memcached:
      condition: service_started
    mongo:
      condition: service_healthy
    elasticsearch:
      condition: service_healthy

services:
  runner:
    <<: *backend
    command: /bin/bash
    ports:
      - "3002:3002"

  rails:
    <<: *backend
    command: bundle exec rails server -b 0.0.0.0
    ports:
      - "3000:3000"
    networks:
      - default
      - frontend
    dns: $DIP_DNS

  sidekiq:
    <<: *backend
    command: bundle exec sidekiq -C config/sidekiq.yml

  webpacker:
    <<: *app
    command: ./bin/webpack-dev-server
    ports:
      - "3035:3035"
    volumes:
      - .:/app:cached
      - rails_cache:/app/tmp/cache
      - bundle:/bundle
      - node_modules:/app/node_modules
      - packs:/app/public/packs
    environment:
      <<: *env
      WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
      BOOTSNAP_CACHE_DIR: /bundle/bootsnap

  postgis:
    image: mdillon/postgis:10
    volumes:
      - .psqlrc:/root/.psqlrc:ro
      - postgis:/var/lib/postgresql/data
    environment:
      PSQL_HISTFILE: /root/log/.psql_history
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
      POSTGRES_DB: companycam_development
    ports:
      - "5432"
    healthcheck:
      test: pg_isready -U postgres -h 127.0.0.1 -d companycam_development
      interval: 5s

  mongo:
    image: mongo
    restart: always
    ports:
      - "27017:27017"
    environment:
      MONGO_INITDB_DATABASE: companycam_development
    volumes:
      - mongodb:/data/db
    healthcheck:
      test: echo 'db.runCommand("ping").ok' | mongo localhost:27017/companycam_development --quiet
      interval: 5s

  memcached:
    image: memcached
    ports:
      - "11211"
    healthcheck:
      disable: true
    #   test: memcached-tool 127.0.0.1:11211 stats
    #   interval: 3s
    #   timeout: 3s
    #   retries: 30

  redis:
    image: redis:5.0-alpine
    ports:
      - 6379
    volumes:
      - redis:/data
    healthcheck:
      test: redis-cli ping
      interval: 1s
      timeout: 3s
      retries: 30

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.8.13
    ports:
      - "9200:9200"
    volumes:
      - elasticsearch:/usr/share/elasticsearch/data
    environment:
      - cluster.name=docker-cluster
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - xpack.security.enabled=false
    healthcheck:
      test: ["CMD", "curl", "http://localhost:9200/_cat/health"]
      interval: 1s
      timeout: 3s
      retries: 30

volumes:
  postgis:
  mongodb:
  redis:
  elasticsearch:
  bundle:
  node_modules:
  rails_cache:
  packs:

networks:
  frontend:
    external:
      name: frontend
  1. Run command
  • dip ngnix up
  • dip rails s
  1. See error

Expected behavior
A clear and concise description of what you expected to happen.
I am able to connect to companycam.local and see the app.

Context (please complete the following information):

  • OS: MacOS Catalina
  • Version 6.1.0

Additional Context
I am running puma-dev presently as we are preparing for the docker switch. I believe that runs on port 80, so not sure if that would conflict since it seems that nginx is receiving the request.

how to use SSH command line

Sorry, being a bit of a dumb user here. Could you explain whether/how I can use SSH commands from within dip shell?

background: I use dip to manage a number of Rails sites all with slightly different hosting (not by me, I inherited them!). For each site I have a 'livepull' command that does a postgres dump of the production db, downloads it, and restores into a dev db for investigating problems. This plays nicely with Heroku. For some sites, I have a .sh file to SSH in and issue a pg_dump command, then SFTP the file locally, and run a pg_restore.

Can I run "SSH [email protected] << EOF pg_dump ....., exit EOF" in dip shell? If I do a 'dip ssh up' first?

feature request: `dip build` command

Hello 👋

Tried running dip build thinking it will directly do a docker-compose build command.

There is the possibility to do it through dip compose build but dip build was a natural step for me to do after seeing that many commands on the first level of semantic hirarchy are already docker related [up, down, stop]

just started using your tool as a replacement for make :) really cool 😄

I could try to implement it if you think is worth the investment and sharing :D

dip ssh add fails after each reboot

After each reboot on -
dip ssh add
Im getting this error:

$ dip ssh add
ssh_data
docker: Error response from daemon: Conflict. The name "/ssh-agent" is already in use by container b86a6ef522e1470b39f8ed9eb8e2e375085a1966db95d305b001a20368e5c175. You have to remove (or rename) that container to be able to reuse that name..
See 'docker run --help'.

And, therefore, I required to remove this container manually.

OS:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.1 LTS
Release:        16.04
Codename:       xenial

docker and docker-compose:

$ docker -v
Docker version 1.12.1, build 23cf638

$ docker-compose -v
docker-compose version 1.8.0, build f3628c7

I think problem here - https://github.com/bibendi/dip/blob/master/src/dip/commands/ssh.cr#L28.
You should run docker start ssh-agent if container already exists.
Or, maybe better set ssh-agent container to 'restart always' ?

Ablity to alias dip to point to a docker container?

Hi,

Thnx for releasing the latest (7.0) version today. I see that the compiled binary is not longer there and i guess that also means we cannot longer install dip with brew?

We can get along with installing the gem but the problematic part in that is that we will need to have ruby installed first on the dev machines and not all our people are ruby minded (frontend devs). Do you think it would be possible to run dip inside a container and would behave like it was installed on the host machine? From my understanding that will be hard cause did will execute docker stuff in the context of the container then and not the host.

Just want to explore the possible alternatives for the decision to not build a compiled binary.

Make it easier to ignore/allow specific environment variables

As far as I can tell, the only way to ignore an environment variable within dip is to add it to the DIP_EARLY_ENV environment variable. This is a reasonable heuristic for what to ignore, but it means that there is an order-dependence to your shell configuration.

What I found is that since I use chruby, which modifies the GEM_HOME and GEM_PATH environment variables, my dip-run containers were not picking up the bundle in my Docker volume and were thus not working.

The reason for that is that my eval "$(dip console)" was being run prior to chruby initializing.

It would be really nice if dip had the ability to allowlist/denylist environment variables to use within the containers. Something like:

environment:
  allowed:
    - BUNDLE_GITHUB__COM
    - RAILS_MASTER_KEY

or

environment:
  denied:
    - GEM_HOME
    - GEM_PATH

I'd be happy to take a crack at an approach if you want.


Aside

I'm not really sure what the current behavior is meant for since docker-compose already handles the environment variables that I need within my project. Why do you pass all environment variables in, instead of relying on docker-compose to manage the environment for you?

less than symbol (<) not working correctly for CLI commands

Describe the bug
We're setting up a subcommand which will automatically import a .sql file into mysql running inside a container. This contains the < symbol, as that required to import the dump, but this doesn't seem to work within the dip context.

To Reproduce
Steps to reproduce the behaviour:

# dip.yml
  mysql:
    description: Run mysql console
    service: mysql
    command: mysql -h mysql_no -u root -d app_development
    subcommands:
      import:
        description: import the specified file into the development database
        service: mysql
        command: mysql -h mysql -u root -proot app_development < MySQL.sql
# command run
$ dip mysql import
# Output
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql  Ver 14.14 Distrib 5.7.33, for Linux (x86_64) using  EditLine wrapper
Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Usage: mysql [OPTIONS] [database]
  -?, --help          Display this help and exit.
  -I, --help          Synonym for -?
snip...

We've been able to bypass this by removing the < MySQL.sql portion of the command, and instead passing that in via the CLI when we run the command, i.e. dip mysql import < MySQL.sql - but would prefer for it to be all inclusive within the dip.yml file.

Expected behavior
It should import the database

Context (please complete the following information):

  • OS: MacOS 11.1
  • Version 6.1.0

Dip does not wrap an actual container command in quotes on Ubuntu

First of all, thank you for the really great, useful and handy tool. I apologize in advance for possible grammar mistakes. Also, I assume I might misunderstand the actual reason of the issue.

Describe the bug
It's impossible to use a container application with arguments on Ubuntu and therefore it's impossible to use advanced shell constructions.

To Reproduce
Steps to reproduce the behavior:

  1. Create any folder, e.g. /tmp/test_project
  2. Create the dip.yml config file in the folder:
version: '2'

compose:
  files:
    - docker-compose.yml
 
 interaction:
    bash:
      service: test
      command: /bin/sh

provision:
  - dip bash -c  'if [[ true ]]; then echo works; fi'
  1. Create the docker-compose.yml config file in the folder:
version: '3.5'

services:
  test:
    image: alpine
    command: tail -f /dev/null
  1. Run command dip provision or dip bash -c 'if [[ true ]]; then echo works; fi' from the folder.
  2. See the error
sh: -c: line 1: syntax error near unexpected token `then'
sh: -c: line 1: `docker-compose --file /home/snthpr1d3/work/dip_bug/docker-compose.yml run --rm test /bin/sh -c if [[ true ]]; then echo works; fi'
ERROR: Command 'dip bash -c  'if [[ true ]]; then echo works; fi'' executed with error

Expected behavior
Performs the shell command correctly and prints "works" as on MacOS environment.

Context (please complete the following information):

  • OS: Ubuntu 21.04
  • Version 7.1.0

Additional context
Don't reproduce on MacOS environment.

As you can see the dip bash -c 'if [[ true ]]; then echo works; fi sample command transcripts into

docker-compose --file /home/snthpr1d3/work/dip_bug/docker-compose.yml run --rm test /bin/sh -c if [[ true ]]; then echo works; fi

which is evidently requires quotes to surround the arguments like this

docker-compose --file /home/snthpr1d3/work/dip_bug/docker-compose.yml run --rm test /bin/sh -c 'if [[ true ]]; then echo works; fi'

as it was in the original config file: dip bash -c 'if [[ true ]]; then echo works; fi'

As I mentioned before, works correctly on MacOS.

run dip with variables

Hello,
can I pass variables to dip manually not in interactive mode?
For example, I would like to run rake db:migrate in different environments. So, I made

docker-compose.yml
services:
  web:
    environment:
      -HANAMI_ENV=${ENV}

and

dip.yml
environment:
  ENV: ${ENV}

And then I tried dip ENV=test bundle exec rake db:migrate, but dip don't accept variable.
Also, as I understand, you make anything like this in https://github.com/bibendi/dip#dip-run

dip version: 3.8.2, binary; Ubuntu 18.04

Add default stacks

Add default stack files.

stacks:
  - ruby
  - rails
  - postgres
  - mysuperstack:
      source: github.com/user/repo/path_to_mysuperstack.yml

interaction:
  services:
    app:
      stacks:
        - ruby
        - rails
      tasks:
        rebuild:
          command: dip bundle exec rake rebuild
    pg:
      stacks:
        - postgres
    superservice:
      stacks:
        - mysuperstack
dip stacks install

It will download yml files:

  • for ruby from bibendi/dip-stacks/ruby.yml
  • for rails from bibendi/dip-stacks/rails.yml
  • for mysuperstack from github.com/user/repo/path_to_mysuperstack.yml

And place it to ~/.dip/stacks/

Example of ruby.yml stack:

irb:
  command: irb
bundle:
  command: bundle
rake:
  command: bundle exec rake

Run command in existing container

Hi, I have defined a rails dip command so to run tests with an environment configured with docker-compose. However it starts a new container each time, so startup is slow. How can I use an existing container if I run docker-compose up beforehand? Compose starts the container with name app-test, but dip starts a new container named app-rails with the name of the command in it. I tried setting container_name: app-test in the dip command but nothing changes. Thanks in advance

Do not show other container names when running command

Hi! I am loving this utility, it makes it easier to work with Docker. I have a quick question: can I somehow hide / remove the "Starting X" messages when running a command, so it looks like that command is not from docker compose/dip? Thanks!

Template parsing error `dip dns ip`

Describe the bug
The following error occurred in https://github.com/bibendi/dip/releases/tag/v7.0.0.

$ dip --version
7.0.0

$ dip dns ip
Template parsing error: template: :1: unexpected unclosed action in command
ERROR: Command 'docker inspect --format {{ .NetworkSettings.Networks.frontend.IPAddress }} dnsdock' executed with error.

Therefore, DIP_DNS is not set and requests between containers will not work.

To Reproduce
Steps to reproduce the behavior:

$ docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
a51e8bb8a1a5   bridge    bridge    local
ea175032c0fb   host      host      local
f3e5cf88a3a5   none      null      local

$ docker container ls -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

$ dip dns up
e40f1db441cad1383d8a1b8b65e46d137c2578588c7407772f9de186839e36e6
9f30d003f9df0cf2af4b4ac3476c3677a23fffd131d6054f3ba2906cff096056

$ docker network ls
NETWORK ID     NAME       DRIVER    SCOPE
a51e8bb8a1a5   bridge     bridge    local
e40f1db441ca   frontend   bridge    local
ea175032c0fb   host       host      local
f3e5cf88a3a5   none       null      local

$ docker container ls -a
CONTAINER ID   IMAGE                           COMMAND                  CREATED          STATUS          PORTS                   NAMES
9f30d003f9df   aacebedo/dnsdock:latest-amd64   "dnsdock --domain=do…"   26 minutes ago   Up 26 minutes   0.0.0.0:56519->53/udp   dnsdock

$ docker network inspect frontend
[
    {
        "Name": "frontend",
        "Id": "e40f1db441cad1383d8a1b8b65e46d137c2578588c7407772f9de186839e36e6",
        "Created": "2021-04-10T02:38:13.757056728Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.20.0.0/16",
                    "Gateway": "172.20.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "9f30d003f9df0cf2af4b4ac3476c3677a23fffd131d6054f3ba2906cff096056": {
                "Name": "dnsdock",
                "EndpointID": "9da2d80f6e762104d27086eb31270f25ddedc710ac5f4c4cb3d500ed24216947",
                "MacAddress": "02:42:ac:14:00:02",
                "IPv4Address": "172.20.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]

$ dip --version
7.0.0

$ dip dns ip
Template parsing error: template: :1: unexpected unclosed action in command
ERROR: Command 'docker inspect --format {{ .NetworkSettings.Networks.frontend.IPAddress }} dnsdock' executed with error.

Expected behavior

No error in v6.1.0.

$ dip --version
6.1.0

$ dip dns ip
172.20.0.2

Context:

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.15.7
BuildVersion:	19H524

$ docker -v
Docker version 20.10.5, build 55c4c88

$ dip --version
7.0.0

$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
Copyright (C) 2007 Free Software Foundation, Inc.

Additional context

I think this commit is the cause.
71baf4e

$ docker inspect --format {{ .NetworkSettings.Networks.frontend.IPAddress }} dnsdock
Template parsing error: template: :1: unexpected unclosed action in command

$ docker inspect --format '{{ .NetworkSettings.Networks.frontend.IPAddress }}' dnsdock
172.20.0.2

$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]

$ ruby -e "::Kernel.system({}, 'docker', 'inspect', '--format', '{{ .NetworkSettings.Networks.frontend.IPAddress }}', 'dnsdock')"
172.20.0.2

$ ruby -e "::Kernel.system({}, 'docker inspect --format {{ .NetworkSettings.Networks.frontend.IPAddress }} dnsdock')"
Template parsing error: template: :1: unexpected unclosed action in command

dyld: Library not loaded: /usr/local/opt/bdw-gc/lib/libgc.1.dylib

Could not make dip working. Reinstall via brew crystal, crystal-lang, glib, bdw-gc, libevent, libyaml, dyld-headers, nothing helps, xcode command line installed and accepted. I've got High Sierra 10.13.2 (17C205).
Tried to find solution, none is working.
Please help!

screen shot 2018-01-26 at 21 44 32

Can I use more than one provision or there have another way to run commands each by each?

I have some requirements, I want to use one command to execute multiple interactions
For example I have a dip.yml like this

interaction:
  rails:
    description: Run Rails commands
    service: rails
    command: bundle exec rails
    subcommands:
      s:
        description: Run Rails server 
        service: rails
        compose:
          run_options: [service-ports, use-aliases]

  yarn:
    description: Run Yarn commands
    service: rails
    command: yarn
    compose_run_options: [no-deps]

I want to use one command like dip start-server。It can run like provision to run

- dip rails s
- dip yarn start

Can I make it happen?

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.