Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for linked containers #74

Closed
sethrosenblum opened this issue Aug 6, 2014 · 30 comments
Closed

Add support for linked containers #74

sethrosenblum opened this issue Aug 6, 2014 · 30 comments
Labels
feature a PR providing a new feature.

Comments

@sethrosenblum
Copy link

The jenkins plugin doesn't currently support linking to other containers. In the command line, you would run like this:

docker run --link othercontainer:alias myimage command

This would need to be added to the HostConfig when starting the container here:

dockerClient.container(container.getId()).start(hostConfig);

@dmelamedcl
Copy link

👍 for that feature. Is there a current workaround for this?

@ewoutp
Copy link

ewoutp commented Oct 7, 2014

+1

1 similar comment
@gdyuldin
Copy link

gdyuldin commented Jan 5, 2015

+1

@spali
Copy link

spali commented Feb 3, 2015

+1
don't know docker-java implementation, but maybe general possibility to add arguments to the "run command" of docker would make it more flexible to configure slaves as required.

@pgokul
Copy link

pgokul commented Feb 11, 2015

+1

@RyanGannon
Copy link

+1 This is the only thing preventing me from using the plugin.

@KostyaSha
Copy link
Member

Docker starts and stop container, why do you need link it?

@RyanGannon
Copy link

Right now I'm trying to create a slave for a test environment. The test involve MySQL. If I were using my own machine I'd use

sudo docker run -d --name db --env MYSQL_ROOT_PASSWORD=password mysql
sudo docker run -d -p 2222:22 --name slave --link db:db myslaveimage

That's a basic example and I may want to add more containers to use for testing/building.

@KostyaSha
Copy link
Member

I think option can be added, but please firstly check that existed configuration and provided options are not enough. Such usage looks like a hardcode of slaves usage. DockerCloud configuration is about running slaves, if you need run additional container for build/test process then AFAIR there is a builder action to run and post-build action to stop it.

@RyanGannon
Copy link

It's core Docker functionality and I would help greatly if I could dynamically provision multiple instances of a container and its linked containers and destroy them afterwards. Also, to be clear, I can't have just one instance of MySQL be shared by myslaveimage.

@magnayn
Copy link
Contributor

magnayn commented Apr 21, 2015

What would be really useful would be the ability to specify a
docker-compose style 'environment' for the build to take place in (of which
the slave is just one potential collaborator).

I keep meaning to see if the docker-compose code will run in jython, as
that'd give a good shortcut to doing this..

On Tue, Apr 21, 2015 at 1:34 PM, Kanstantsin Shautsou <
notifications@github.com> wrote:

I think option can be added, but please firstly check that existed
configuration and provided options are not enough. Such usage looks like a
hardcode of slaves usage. DockerCloud configuration is about running
slaves, if you need run additional container for build/test process then
AFAIR there is a builder action to run and post-build action to stop it.


Reply to this email directly or view it on GitHub
#74 (comment)
.

@RyanGannon
Copy link

Yes, compose would be great. Feed the plugin a compose file instead. But for now linked containers are really important to me.

@magnayn
Copy link
Contributor

magnayn commented Apr 21, 2015

Shouldn't be too hard to add as it's just an API parameter and an extra UI
control.

It's a pity jenkinsci/jenkins#1448 still
languishes, as this would allow potentially the links to be specified
within the job, rather than the template.

On Tue, Apr 21, 2015 at 1:43 PM, Ryan Gannon notifications@github.com
wrote:

Yes, compose would be great. Feed the plugin a compose file instead. But
for now linked containers are really important to me.


Reply to this email directly or view it on GitHub
#74 (comment)
.

@RyanGannon
Copy link

If I had the free time I'd do this myself, docker-java already has it in its API.

@RyanGannon
Copy link

I just want to be able to use Docker from Jenkins, on a remote machine.

@KostyaSha
Copy link
Member

Links method appeared in java-docker library, i have version update in my current working branch, so will look later on adding options.

@RyanGannon
Copy link

Thank you.

@KostyaSha KostyaSha self-assigned this Apr 23, 2015
@KostyaSha KostyaSha added the enhancement A PR providing an enhancement to existing functionality. label Apr 23, 2015
@KostyaSha
Copy link
Member

@RyanGannon could you describe steps of containers run (what and where) do you expect for you use case?
Do you want link something to provisioned container with jenkins slave or run two plain slaves (without jenkins slave) as job steps? I think docker start/stop before job execution and after may simulate compose.

@KostyaSha KostyaSha added feature a PR providing a new feature. and removed enhancement A PR providing an enhancement to existing functionality. labels Aug 14, 2015
@KostyaSha KostyaSha removed their assignment Oct 14, 2015
@superbob
Copy link

I'm not using this plugin currently, but I might use it on a near future and this option would help me greatly.
Currently on my jenkins environment I've installed docker and pulled 3 images (database, rabbitmq, zookeeper). I've created one container for each of these images (database-1, rabbitmq-1, zookeeper-1) specifying a port-mapping for communications between the host and the containers.

On pre-step when the job start, it start these containers (docker start databse-1 rabbitmq-1 zookeeper-1). They are started within a "shell script" pre-step.
Then the build run.
Finally at post-step a docker stop command is issued (docker stop databse-1 rabbitmq-1 zookeeper-1).

What I'd like to have with this plugin is an option to specify a link as either an existing docker container to start/stop or an image to run and clean.

@fsamir
Copy link

fsamir commented Dec 31, 2015

+1
Regardless of use case, the template "runs" a container, therefore it would make sense to allow the user to input any valid "run" argument, IMO.

Using the build steps workaround, suggested previously, adds unnecessary complication to the job configuration.
For example, if a build job is restricted to a particular container, then there needs to be another nested job just to start the container, otherwise the main build job will never start, because there are no slaves matching it.

@davidorlea
Copy link

+1

Is there a status update on the progress?

@rcbop
Copy link

rcbop commented May 25, 2016

+1 I'm also in a great need of that feature, I see that withLinks() method was implemented in docker-java lib's class CreateContainerCmd.java https://github.com/docker-java/docker-java/blob/master/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java should be easy now right?

@counsellors
Copy link

+1
The PR jenkinsci/jenkins#1448 is open now. Is there another way to implement the option --link?

@cpfeiffer
Copy link

I also like the idea of specifying a docker-compose file to launch a set of linked plugins.

A bit of research led me to https://github.com/gesellix/docker-client, which provides Java API for docker including support for docker-compose via https://github.com/docker-client/docker-compose-v3.

I guess replacing docker-java with docker-client is not an option right now, but maybe docker-compose-v3 could be used to read the docker-compose file and reproduce the compose functionality with docker-java.

@ndeloof
Copy link
Contributor

ndeloof commented Oct 10, 2017

This feature is better addressed today by docker-slaves-plugin
I have plan to backport some ideas into docker-plugin, so composition becomes a first class citizen here.

@ndeloof ndeloof closed this as completed Oct 10, 2017
@daroay
Copy link

daroay commented Apr 13, 2018

@ScottBrenner
Copy link

Sorry for posting on an old issue -

Container links are a legacy feature of Docker and may eventually be removed. Is there a recommended new/better way to do this?

@pjdarton
Copy link
Member

My (limited) understanding is that, for settings where a set of inter-connected/related containers are needed, "all the cool kids" are using Kubernetes these days.

It's certainly outside the purpose of this plugin - this plugin is for providing Jenkins with slave nodes, using docker to do so - anything else that can be done by docker is probably best done by issuing docker CLI commands on a slave node that has its own docker daemon.

@pjdarton
Copy link
Member

Yes, for stuff like this, you probably want the extra control afforded by pipelines, and hence will be using the docker-workflow-plugin instead of the docker-plugin (as per JENKINS-49567)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a PR providing a new feature.
Projects
None yet
Development

No branches or pull requests