63 Commits

Author SHA1 Message Date
Chris Roberts
84d3a5fe47 Update compose tests to pass fully through Util::Subprocess 2021-07-12 09:54:56 -07:00
sophia
04977677f1 Pass in docker command opts as a map 2021-07-08 12:15:06 -05:00
Chris Roberts
c5664e479e Fix matching on build output for docker provider 2021-04-13 13:23:43 -07:00
Brian Cain
cfb9a6457e
Remove obtaining name from docker container info 2020-05-12 11:26:48 -07:00
Brian Cain
b2d9abe344
Fixes #9067: Ensure new containers don't grab existing bound ports
Prior to this commit, if a created but exited container bound a port,
and a new container grabed that same port (say for an ssh port forward),
when the initial container came back up it would fail because the port
also got bound to the second container. This commit fixes that behavior
by first looking at what containers are already bound prior to creating
a container.
2020-05-11 10:17:22 -07:00
Jaroslav Prokop
5208032594 Docker provider: catch container name when using podman.
When user is using podman's docker CLI emulation the containers would
fail to enter running state because the docker driver could not catch
the container name. This commit fixes that by adding a check if podman
docker emulation is used and pick the container hash correctly from the
output.
2020-03-25 19:34:31 +01:00
Sophia Castellarin
2dadeb3ee5
Merge pull request #11461 from soapy1/get-docker-image-id
Get correct docker image from build output
2020-03-24 09:27:20 -05:00
sophia
324294993e Check for docker buildkit output first
When buildkit is enabled docker will write out
`writing image <image id>`
When buildkit is not enables docker will write out
`Successfully builld <image id>`
It is more likely that searching for the `writing image` will not
clash with build output than when searching for `Successfully built`.
eg. when installing python packages with pip, it is common to use
the verbage `Successfully built`.
2020-03-23 13:54:49 -05:00
sophia
380c25a7ae Get last image id from docker output 2020-03-23 10:10:19 -05:00
Terry Burton
c9ca7b8f57
docker provider: Don't explode when removing an image if it is in use
Output from recent Docker has changed:

    Stderr: Error response from daemon: conflict: unable to delete 0ba49dd235e5 (cannot be forced) - image is being used by running container 250bbe980448

Fixes #7245
2020-01-30 20:06:32 +00:00
Brian Cain
2901dae948
Add option for docker executor to handle stderr from results
Instead of always joining stdout and stderr, only join the two if the
caller explicitly asks for it. Otherwise, only return stdout.
2019-11-22 12:04:09 -08:00
Brian Cain
4d70856b8a
Enhance docker build matching for determining built container ID
Prior to this commit, docker would look for a container ID based on
"Successfully built" string. This output does not exist if a user has
enabled the experimental feature buildkit. This commit updates the build
behavior to match against both kinds of outputs, and instead of using
`scan`, it uses MatchData and groups the container id with match group
name `:id` instead of making hard assumptions with the matches being
contained inside arrays from scan.
2019-11-19 10:59:28 -08:00
Juha Ruotsalainen
4fc8b07974
Removed the word 'done'.
There are cases, when 'done' is prefix with a duration, like `... 0.1s done`.
2019-11-19 10:02:03 -08:00
Rumpu-Jussi
f3629ebd09
Buildkit-based output processed a bit differently. 2019-11-19 10:02:03 -08:00
Juha Ruotsalainen
8041d0ae78
Build quietly and capture the image hash
At least on macOS combo Catalina + Docker engine 19.03.4 + Docker desktop 2.1.0.4 + vagrant 2.2.6 the original `matches = result.scan(/Successfully built (.+)$/i)` -line fails to generate a match. With this change I can `vagrant up --provider=docker` successfully.
2019-11-19 10:02:03 -08:00
Brian Cain
eb75431c4a
Update docker driver and docker driver unit tests 2019-03-20 14:50:28 -07:00
Chris Roberts
a645ce3c25 Docker provider networking support updates
Use `mask` option for defining subnet on network configuration. Allow
options to be passed through using hash scoping and docker_network and
docker_connect prefixes. Enable public networks. Allow configuration
to define pre-existing networks by name.
2019-03-19 11:44:33 -07:00
Chris Roberts
1224622387 Remove container inspection caching and Exception rescue
Container inspection is caching data on first lookup. This will
result in incorrect data being returned on subsequent lookups if
a different `cid` value is provided. Also removed rescue of
the `Exception` class as this generally should never happen; rescue
of StandardError will be enough.
2019-03-19 11:44:22 -07:00
Brian Cain
5ed5868067
Inspect networks before creating new ones
This commit updates the behavior of how the docker provider creates new
docker networks. It looks at each existing network to see if the
requested subnet has already been configured in the docker engine. If
so, Vagrant will use that network rather than creating a new one. This
includes networks not created by Vagrant. Vagrant will not clean up
these networks if created outside of Vagrant.
2019-03-12 10:36:57 -07:00
Brian Cain
b78dada2c7
Fix docker driver handling cli flags
Make opts argument set to nil instead of splat to make Travis Ruby 2.3
happy
2019-03-05 10:57:05 -08:00
Brian Cain
4080f9e64d
Log warning if docker network inspect fails to return json 2019-03-04 10:25:10 -08:00
Brian Cain
000457a012
Update how docker network provider creates networks
This commit updates the docker network provider to only create networks
by subnet rather than per-container.
2019-03-01 16:07:53 -08:00
Brian Cain
b5a092397f
Add new function for handling vagrant options to docker network cli
flags
2019-03-01 08:34:43 -08:00
Brian Cain
dc5f8c66f2
Add todo comment for future fixup 2019-03-01 08:34:43 -08:00
Brian Cain
4dc5f7c330
Add basic ability to configure some networks for containers 2019-03-01 08:34:43 -08:00
Brian Cain
e860c7709d
Begin to setup and configure docker networks for containers 2019-03-01 08:34:43 -08:00
Brian Cain
67ea15126d
Make opts var optional for docker driver methods 2019-03-01 08:34:43 -08:00
Brian Cain
ec2e0380ee
Add basic docker driver methods for docker network subcommand 2019-03-01 08:34:43 -08:00
Brian Cain
5d2d784ae7
(#9085) - Add test for converting windows paths
This commit adds a test for checking that a windows path for mounting a
volume in a container is properly converted into something that's
usable.
2018-08-08 10:30:04 -07:00
mihab
03178bbe04 Fixes #9085: Cannot up a machine with Docker Toolbox and Git Bash 2018-03-01 21:38:39 +01:00
Dimitrios Kouzis-Loukas
51716c5ef0 fix for issue 8608 2017-08-27 23:56:47 -04:00
Chris Roberts
deba93ce5c Add optional support for docker-compose
Adds configuration switch to enable using docker-compose
to create and manage docker containers.
2017-05-12 15:09:30 -07:00
Chris Roberts
5d83c03bfc Properly handle synced folders in docker provider on WSL 2017-05-12 14:05:12 -07:00
Theron Boerner
391c5be08e Remove --interactive flag from Docker command
See: GH-7597. Due to the childprocess gem setting STDIN to a pipe,
Docker will fail as it requires STDIN to be a TTY if run with
--interactive.
2016-10-05 14:38:20 -05:00
Mitchell Hashimoto
c2cae80de5 providers/dock: pull image prior to starting 2015-07-08 10:09:15 -06:00
Mitchell Hashimoto
b656bf4ae5 providers/docker: build output [GH-3739] 2014-10-23 15:03:09 -07:00
Mitchell Hashimoto
296d0639cc providers/docker: support auth [GH-4042] 2014-10-22 13:12:31 -07:00
Mitchell Hashimoto
57a1269e35 providers/docker: read the container ID properly 2014-10-22 09:33:57 -07:00
Mitchell Hashimoto
9d4ab18f42 providers/docker: stop_timeout [GH-4504] 2014-10-21 17:50:45 -07:00
Mitchell Hashimoto
e749eaa039 providers/docker: more robustly detect built image [GH-4598] 2014-10-21 17:44:48 -07:00
Leo Simons
fec14cf04c Use -f argument to rm to force-remove files.
When using pty=true, removing files using sudo may request confirmation,
which will hang the connection.

Similarly, sometimes assumptions about file existence may be wrong and
in those cases it seems better to continue on as long as the file does
not exist, so -f makes sense there, too.
2014-08-29 10:51:31 +02:00
Paris Holley
802d17a248 remove vm by default when using docker run 2014-08-09 12:03:35 -07:00
Gosha Arinich
faba9bdae9 Revert "providers/docker: Container links are an array, not a hash"
This reverts commit b68cb6d7b408a494dccb96383b20387de7db0339.
2014-05-08 21:10:37 +03:00
Mitchell Hashimoto
030c1ee481 providers/docker: build_args [GH-3684] 2014-05-07 18:41:24 -07:00
Fabio Rehm
b68cb6d7b4 providers/docker: Container links are an array, not a hash 2014-05-07 12:12:16 -03:00
Mitchell Hashimoto
92df8cf6ae Handle a lot of TODOs 2014-04-29 16:50:58 -07:00
Mitchell Hashimoto
0bb523ebb0 providers/docker: use ssh_run if asking for stdin on execute 2014-04-29 16:27:22 -07:00
Mitchell Hashimoto
e90e45a8fb providers/docker: pty flag, not functional yet 2014-04-29 15:51:32 -07:00
Mitchell Hashimoto
d7ecd99e2e providers/docker: be more lenient about deleting built image 2014-04-28 09:36:55 -07:00
Mitchell Hashimoto
c818a14072 providers/docker: expose ports 2014-04-27 18:37:25 -07:00