Code Monkey home page Code Monkey logo

compose-switch's Introduction

The Moby Project

Moby Project logo

Moby is an open-source project created by Docker to enable and accelerate software containerization.

It provides a "Lego set" of toolkit components, the framework for assembling them into custom container-based systems, and a place for all container enthusiasts and professionals to experiment and exchange ideas. Components include container build tools, a container registry, orchestration tools, a runtime and more, and these can be used as building blocks in conjunction with other tools and projects.

Principles

Moby is an open project guided by strong principles, aiming to be modular, flexible and without too strong an opinion on user experience. It is open to the community to help set its direction.

  • Modular: the project includes lots of components that have well-defined functions and APIs that work together.
  • Batteries included but swappable: Moby includes enough components to build fully featured container systems, but its modular architecture ensures that most of the components can be swapped by different implementations.
  • Usable security: Moby provides secure defaults without compromising usability.
  • Developer focused: The APIs are intended to be functional and useful to build powerful tools. They are not necessarily intended as end user tools but as components aimed at developers. Documentation and UX is aimed at developers not end users.

Audience

The Moby Project is intended for engineers, integrators and enthusiasts looking to modify, hack, fix, experiment, invent and build systems based on containers. It is not for people looking for a commercially supported system, but for people who want to work and learn with open source code.

Relationship with Docker

The components and tools in the Moby Project are initially the open source components that Docker and the community have built for the Docker Project. New projects can be added if they fit with the community goals. Docker is committed to using Moby as the upstream for the Docker Product. However, other projects are also encouraged to use Moby as an upstream, and to reuse the components in diverse ways, and all these uses will be treated in the same way. External maintainers and contributors are welcomed.

The Moby project is not intended as a location for support or feature requests for Docker products, but as a place for contributors to work on open source code, fix bugs, and make the code more useful. The releases are supported by the maintainers, community and users, on a best efforts basis only. For customers who want enterprise or commercial support, Docker Desktop and Mirantis Container Runtime are the appropriate products for these use cases.


Legal

Brought to you courtesy of our legal counsel. For more context, please see the NOTICE document in this repo.

Use and transfer of Moby may be subject to certain restrictions by the United States and other governments.

It is your responsibility to ensure that your use and/or transfer does not violate applicable laws.

For more information, please see https://www.bis.doc.gov

Licensing

Moby is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

compose-switch's People

Contributors

ad-m avatar alexandregv avatar foxboron avatar lekum avatar markdegrootnl avatar mat007 avatar modem7 avatar ndeloof avatar nekketsuuu avatar nicksieger avatar ulyssessouza 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

compose-switch's Issues

docker-compose container name separator switches between `-` and `_`.

  • I have tried with the latest version of Docker Desktop
  • I have tried disabling enabled experimental features
  • I have uploaded Diagnostics
  • Diagnostics ID: B6CD6541-132F-4401-A847-57D0C1C6D921/20211209193540

Actual behavior

docker-compose switches between - and _ as a container name separator between releases.

Expected behavior

docker-compose must consistently use - as a container name separator.

Information

  • Running with Docker Desktop 4.3.0 (71786) on Windows 11, with the WSL2 backend.
  • Docker Compose V2 is checked in the settings. docker-compose version is v2.2.1.
  • This seems to have appeared with the 4.3.0 update. It is not noticed unless you rebuild your environment. I.e. existing environments continue to use - as the container name separator.
  • I had the same issue a couple of months back. That time, it was also fixed with an update.

Steps to reproduce the behavior

  • Sample docker-compose file:
    version: '3.4'
    
    services:
      db:
        image: postgres:latest
        restart: always
        ports:
          - "127.0.0.1:1020:5432"
        volumes:
          - postgres:/var/lib/postgresql/data
        env_file:
          - .env
        environment:
          - PGDATA=/var/lib/postgresql/data/pgdata
    volumes:
      postgres:
  • Steps:
    docker-compose -f docker-compose-test.yaml -p separator-test up
    # creates separator-test_db_1
    docker-compose -f docker-compose-test.yaml -p separator-test down
    sudo wget -q https://github.com/docker/compose/releases/download/v2.2.1/docker-compose-linux-x86_64 -O /usr/local/bin/docker-compose-v2.2.1-gh
    sudo ln -sf /usr/local/bin/docker-compose-v2.2.1-gh /usr/bin/docker-compose
    docker-compose -f docker-compose-test.yaml -p separator-test up
    # creates separator-test-db-1
    docker-compose -f docker-compose-test.yaml -p separator-test down
    sudo ln -sf /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-compose /usr/bin/docker-compose /usr/bin/docker-compose

Several installation script errors

The use case is that I want to install docker-compose v2 and then install compose-switch to translate docker-compose v1 commands from an older project.

But on my brand-new Ubuntu 20.04 server, docker-compose v1 is not installed. This causes a problem when using the install script to install compose-switch.

The following line:

COMPOSE=$(command -v docker-compose)

will cause a return code of 127 on $? (as docker-compose doesn't exist), which stops the entire script in its tracks due to the set -e on line 3:

If I comment out the set -e then the script can proceed further. But then we encounter another error on line 34:

echo "Configuring `docker-compose` alternatives"

as the backticks cause the shell to try to execute docker-compose, which doesn't exist.

If I turn the backticks into normal single quotes ' then the script can proceed further and finishes the installation.

The backticks seem like a straightforward fix but I'm not sure what the intention is behind the set -e was -- if anyone could explain that I'd be happy to make a pull request to fix these issues.

update-alternatives doesn't exist on every distro

I appreciate that this tool exists, but upate-alternatives / alternatives hardly exists everywhere (e.g. coreos, flatcar, etc...). It would be helpful if you could provide quickstart instructions on how to use the tool such a scenario.

This way people won't just version lock themselves to the latest v1 binary when they realize all their automations based on docker-compose are broken.

Need to pass `--compatibility`-flag

When running without --compatibility-flag the new docker compose will use a hyphen for the hostname instead of an underscore. This breaks compatibility with old scripts. I believe the new flag was introduce for exactly solving such problems and compose-switch should make use of it.

`docker-compose config` fails with "undefined network default" error when `default` network is specified for a service with docker compose v2.2.1+

This issue was tested with compose-switch v1.0.3.

Here is a relatively minimal docker-compose.yml that can be used to reproduce the issue:

version: '3.9'
services:
  helloworld:
    image: hello-world:latest
    networks:
      default:

I have run a few tests to try and track down when this issue started. It seems that this occurs with docker compose v2.2.1+. Failure cases in italics:

(the directory/project name is compose-regression)

1. When run through compose-switch v1.0.3, with docker compose v2.1.1:

$ docker-compose config
services:
  helloworld:
    image: hello-world:latest
    networks:
      default: null
networks:
  default:
    name: compose-regression_default

2. When run through docker compose v2.1.1 directly:

$ docker compose config
services:
  helloworld:
    image: hello-world:latest
    networks:
      default: null
networks:
  default:
    name: compose-regression_default

3. When run through compose-switch v1.0.3, with docker compose v2.2.1:

$ docker-compose config
service "helloworld" refers to undefined network default: invalid compose project

4. When run through docker compose v2.2.1 directly:

$ docker compose config
services:
  helloworld:
    image: hello-world:latest
    networks:
      default: null
networks:
  default:
    name: compose-regression_default

5. When run though compose-switch v1.0.3, with docker compose v2.2.2 (latest at the time of writing)

$ docker-compose config
service "helloworld" refers to undefined network default: invalid compose project

6. When run with docker compose v2.2.2 (latest at the time of writing) directly:

$ docker compose config
services:
  helloworld:
    image: hello-world:latest
    networks:
      default: null
networks:
  default:
    name: compose-regression_default

`apt install` for compose-switch?

Any reason why compose-switch is an outlier in terms of not being able to be apt install'd?

Would be really great if we could install it just like docker-ce and docker-compose-plugin instead of having to manually download the binary, update-alternatives, etc.

Panic on empty project-directory

Description
Panic in cobra

Steps to reproduce the issue:

  1. docker-compose --project-directory "" ps

Describe the results you received:

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/docker/compose-switch/redirect.Convert(0xc0000b8010, 0x4, 0x4, 0x9, 0xc0000c2628, 0x1)
        /home/runner/go/pkg/mod/github.com/docker/[email protected]/redirect/convert.go:32 +0x8ba
main.main.func1(0xc0000bc780, 0xc0000b8010, 0x4, 0x4, 0x0, 0x0)
        /home/runner/work/compose-v1v2-switch/compose-v1v2-switch/main.go:59 +0x14d
github.com/spf13/cobra.(*Command).execute(0xc0000bc780, 0xc0000b8010, 0x4, 0x4, 0xc0000bc780, 0xc0000b8010)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000bc780, 0xc000096df0, 0x0, 0x160d660)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:902
main.main()
        /home/runner/work/compose-v1v2-switch/compose-v1v2-switch/main.go:68 +0x185

Describe the results you expected:
Hmm, error or something like that

Output of docker compose version:

Docker Compose version v2.5.1

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.8.2)
  compose: Docker Compose (Docker Inc., v2.5.1)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 20
 Server Version: 20.10.14
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc version: v1.0.3-0-gf46b6ba
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.10.104-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 9.73GiB
 Name: docker-desktop
 ID: UYE6:X3OH:4K6T:V3ZQ:EST7:QJ4X:2JR6:B6SP:ER4V:PI55:QW23:2KLX
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

How to remove this script?

The script works perfectly, but i need just compose v1 for my project. How do i revert or uninstall the sh script?

install_on_linux.sh does not work with default compose install

The documentation says for the compose plugin to be installed into the users .docker folder. However the install_on_linux.sh script has to be run as root to allow for file creation in /usr/local/bin

The root user however doesn't have compose v2 installed, and the install script then fails (without any output).

Lower case project name when converting to `docker compose`

docker compose (since 2.5.1) has required the project name to be only lower case (and no . ) - it would be nice if compose-switch would auto-convert any give project name option to lower case. Thus continuing to support the V1 spec against the V2 command.

--log-level is a string flags

Hello.

--log-level is defined as a boolean option

boolflags = []string{
"--debug", "-D",
"--verbose",
"--log-level",
"--l",
"--tls",
"--tlsverivy",
}
stringflags = []string{
"--tlscacert",
"--tlscert",
"--tlskey",
"--host", "-H",
"--context",
}

It is not right. Thiis option takes string argument.

  --log-level LEVEL           Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)

CC: @potiuk

Related issue: apache/airflow#18725

Update the installation process

Might be like that (Ubuntu 20.04.3 LTS):

1 - Ensure you have installed docker-compose.
$ apt install docker-compose

2 - download compose-switch binary for your architecture
$ curl -fL https://github.com/docker/compose-switch/releases/download/v1.0.4/docker-compose-linux-amd64 -o /usr/bin/compose-switch

3 - make compose-switch executable
$ chmod +x /usr/bin/compose-switch

4 - rename docker-compose binary to docker-compose-v1
$ mv /usr/bin/docker-compose /usr/bin/docker-compose-v1

5 - define an "alternatives" group for docker-compose command:
$ update-alternatives --install /usr/bin/docker-compose docker-compose /usr/bin/docker-compose-v1 1
$ update-alternatives --install /usr/bin/docker-compose docker-compose /usr/bin/compose-switch 99

Question | compose-switch points to docker-compose v1?

I followed the manual install from the README but it would seem as though compose-switch points to docker-compose v1 and not docker compose v2.

$ compose-switch --version
docker-compose version 1.29.2, build 5becea4c

$ docker compose version
Docker Compose version v2.0.1

$ docker-compose --version
docker-compose version 1.29.2, build 5becea4c

Output from update-alternatives:

$ update-alternatives --config docker-compose
There are 2 choices for the alternative docker-compose (providing /usr/local/bin/docker-compose).

  Selection    Path                              Priority   Status
------------------------------------------------------------
* 0            /usr/local/bin/compose-switch      99        auto mode
  1            /usr/local/bin/compose-switch      99        manual mode
  2            /usr/local/bin/docker-compose-v1   1         manual mode

Am I missing something?

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.