provisioners/docker: auto-assigned name shouldn't have / [GH-3216]
This commit is contained in:
parent
c4c8dbc888
commit
374d1c495a
|
@ -33,6 +33,8 @@ BUG FIXES:
|
|||
longer be shown in plaintext in the output. [GH-3203]
|
||||
- guests/linux: SMB mount works with passwords with symbols. [GH-3202]
|
||||
- providers/hyperv: Check for PowerShell features. [GH-3398]
|
||||
- provisioners/docker: Don't automatically generate container name with
|
||||
a forward slash. [GH-3216]
|
||||
- provisioners/shell: Empty shell scripts don't cause errors. [GH-3423]
|
||||
- synced\_folders/smb: Only set the chmod properly by default on Windows
|
||||
if it isn't already set. [GH-3394]
|
||||
|
|
|
@ -43,7 +43,8 @@ module VagrantPlugins
|
|||
@machine.ui.info(I18n.t("vagrant.docker_running", name: name))
|
||||
@machine.communicate.sudo("mkdir -p #{cids_dir}")
|
||||
run_container({
|
||||
name: name
|
||||
name: name,
|
||||
original_name: name,
|
||||
}.merge(config))
|
||||
end
|
||||
end
|
||||
|
@ -75,9 +76,16 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def create_container(config)
|
||||
name = config[:name]
|
||||
|
||||
# If the name is the automatically assigned name, then
|
||||
# replace the "/" with "-" because "/" is not a valid
|
||||
# character for a docker container name.
|
||||
name = name.gsub("/", "-") if name == config[:original_name]
|
||||
|
||||
args = "--cidfile=#{config[:cidfile]} "
|
||||
args << "-d " if config[:daemonize]
|
||||
args << "--name #{config[:name]} " if config[:name] && config[:auto_assign_name]
|
||||
args << "--name #{name} " if name && config[:auto_assign_name]
|
||||
args << config[:args] if config[:args]
|
||||
@machine.communicate.sudo %[
|
||||
rm -f #{config[:cidfile]}
|
||||
|
|
|
@ -137,8 +137,11 @@ In addition to the name, the `run` method accepts a set of options, all optional
|
|||
* `args` (string) - Extra arguments for [`docker run`](http://docs.docker.io/en/latest/commandline/cli/#run)
|
||||
on the command line. These are raw arguments that are passed directly to Docker.
|
||||
|
||||
* `auto_assign_name` (boolean) - If true, the `-name` of the container will
|
||||
be set to the first argument of the run. By default this is true.
|
||||
* `auto_assign_name` (boolean) - If true, the `--name` of the container will
|
||||
be set to the first argument of the run. By default this is true. If the
|
||||
name set contains a "/" (because of the image name), it will be replaced
|
||||
with "-". Therefore, if you do `d.run "foo/bar"`, then the name of the
|
||||
container will be "foo-bar".
|
||||
|
||||
* `daemonize` (boolean) - If true, the "-d" flag is given to `docker run` to
|
||||
daemonize the containers. By default this is true.
|
||||
|
|
Loading…
Reference in New Issue