3
3
if fact ( 'kernel' ) == 'windows'
4
4
docker_args = 'docker_ee => true'
5
5
default_image = 'winamd64/hello-seattle'
6
- default_image_tag = 'nanoserver-sac2016'
6
+ default_image_tag = if fact ( 'os.release.major' ) == '2019'
7
+ 'nanoserver'
8
+ else
9
+ 'nanoserver-sac2016'
10
+ end
7
11
default_digest = 'sha256:dcba85354678b50608b8c40ec6d17cce063a224aa0e12b6a55dc47b67f039e75'
8
12
second_image = 'winamd64/hola-mundo'
9
13
default_dockerfile = 'C:/Users/Administrator/AppData/Local/Temp/Dockerfile'
14
18
default_docker_run_arg = "restart => 'always', net => 'nat',"
15
19
default_run_command = 'ping 127.0.0.1 -t'
16
20
docker_command = '"/cygdrive/c/Program Files/Docker/docker"'
17
- default_docker_exec_lr_command = 'cmd /c "ping 127.0.0.1 -t > c:\windows\temp \test_file.txt"'
18
- default_docker_exec_command = 'cmd /c "echo test > c:\windows\temp \test_file.txt"'
19
- docker_mount_path = 'C:/Users/Administrator/AppData/Local/Temp '
21
+ default_docker_exec_lr_command = 'cmd /c "ping 127.0.0.1 -t > C:\Users\Public \test_file.txt"'
22
+ default_docker_exec_command = 'cmd /c "echo test > C:\Users\Public \test_file.txt"'
23
+ docker_mount_path = 'C:/Users/Public/DockerVolume '
20
24
storage_driver = 'windowsfilter'
21
25
else
22
26
docker_args = if fact ( 'os.family' ) == 'RedHat'
@@ -313,7 +317,7 @@ class { 'docker': #{docker_args} }
313
317
314
318
it 'creates a new image based on a Dockerfile' do
315
319
run_cmd = if fact ( 'osfamily' ) == 'windows'
316
- 'RUN echo test > C:\\Windows\\Temp \\Dockerfile_test.txt'
320
+ 'RUN echo test > C:\\Users\\Public \\Dockerfile_test.txt'
317
321
else
318
322
"RUN echo test > #{ dockerfile_test } "
319
323
end
@@ -339,7 +343,7 @@ class { 'docker': #{docker_args} }
339
343
# A sleep to give docker time to execute properly
340
344
sleep 4
341
345
if fact ( 'osfamily' ) == 'windows'
342
- shell ( "#{ docker_command } run alpine_with_file cmd /c dir Windows \\ \\ Temp " ) do |r |
346
+ shell ( "#{ docker_command } run alpine_with_file cmd /c dir Users \\ \\ Public " ) do |r |
343
347
expect ( r . stdout ) . to match ( %r{_test.txt} )
344
348
end
345
349
else
@@ -467,7 +471,7 @@ class { 'docker': #{docker_args}
467
471
468
472
container_id = shell ( "#{ docker_command } ps | awk 'FNR == 2 {print $1}'" )
469
473
if fact ( 'osfamily' ) == 'windows'
470
- shell ( "#{ docker_command } exec #{ container_id . stdout . strip } cmd /c dir Windows \\ \\ Temp " ) do |r |
474
+ shell ( "#{ docker_command } exec #{ container_id . stdout . strip } cmd /c dir Users \\ \\ Public " ) do |r |
471
475
expect ( r . stdout ) . to match ( %r{test_file.txt} )
472
476
end
473
477
else
@@ -555,6 +559,11 @@ class { 'docker': #{docker_args} }
555
559
#{ default_docker_run_arg }
556
560
}
557
561
562
+ file { '#{ docker_mount_path } ':
563
+ ensure => directory,
564
+ before => File['#{ docker_mount_path } /test_mount.txt'],
565
+ }
566
+
558
567
file { '#{ docker_mount_path } /test_mount.txt':
559
568
ensure => present,
560
569
before => Docker::Run['container_3_4'],
@@ -568,7 +577,7 @@ class { 'docker': #{docker_args} }
568
577
sleep 4
569
578
container_id = shell ( "#{ docker_command } ps | awk 'FNR == 2 {print $1}'" )
570
579
if fact ( 'osfamily' ) == 'windows'
571
- shell ( "#{ docker_command } exec #{ container_id . stdout . strip } cmd /c dir Users\\ \\ Administrator \\ \\ AppData \\ \\ Local \\ \\ Temp \\ \\ mnt" ) do |r |
580
+ shell ( "#{ docker_command } exec #{ container_id . stdout . strip } cmd /c dir Users\\ \\ Public \\ \\ DockerVolume \\ \\ mnt" ) do |r |
572
581
expect ( r . stdout ) . to match ( %r{test_mount.txt} )
573
582
end
574
583
else
@@ -874,7 +883,7 @@ class { 'docker': #{docker_args} }
874
883
875
884
container_id = shell ( "#{ docker_command } ps | awk 'FNR == 2 {print $1}'" )
876
885
if fact ( 'osfamily' ) == 'windows'
877
- shell ( "#{ docker_command } exec #{ container_id . stdout . strip } cmd /c dir Windows \\ \\ Temp " ) do |r |
886
+ shell ( "#{ docker_command } exec #{ container_id . stdout . strip } cmd /c dir Users \\ \\ Public " ) do |r |
878
887
expect ( r . stdout ) . to match ( %r{test_file.txt} )
879
888
end
880
889
else
@@ -912,7 +921,7 @@ class { 'docker': #{docker_args} }
912
921
sleep 4
913
922
914
923
if fact ( 'osfamily' ) == 'windows'
915
- shell ( "#{ docker_command } exec #{ container_name } cmd /c dir Windows \\ \\ Temp " ) do |r |
924
+ shell ( "#{ docker_command } exec #{ container_name } cmd /c dir Users \\ \\ Public " ) do |r |
916
925
expect ( r . stdout ) . not_to match ( %r{test_file.txt} )
917
926
end
918
927
else
@@ -944,7 +953,7 @@ class { 'docker': #{docker_args} }
944
953
sleep 4
945
954
946
955
if fact ( 'osfamily' ) == 'windows'
947
- shell ( "#{ docker_command } exec #{ container_name } cmd /c dir Windows \\ \\ Temp " ) do |r |
956
+ shell ( "#{ docker_command } exec #{ container_name } cmd /c dir Users \\ \\ Public " ) do |r |
948
957
expect ( r . stdout ) . to match ( %r{test_file.txt} )
949
958
end
950
959
else
0 commit comments