Powershell Variables unable to use with --link $VARIABLE:<name>

Expected behavior

$WEB_CID = docker run -d nginx
docker run -d --link $WEB_CID:insideweb dockerinaction/ch2_agent

In Poweshell, Docker for Windows should work with the $WEB_CID variables for the actual CIDs for the --link

Actual behavior

PS C:\Users\tonyh\OneDrive\Work\2015-05-05-Docker> docker rm -vf (docker ps -a -q)
b0e249ef5e64
ac351c56c89b
PS C:\Users\tonyh\OneDrive\Work\2015-05-05-Docker> $WEB_CID = docker run -d nginx
PS C:\Users\tonyh\OneDrive\Work\2015-05-05-Docker> $WEB_CID
2278d27e0a2bdc1da0d6e77b8352d2146c7190a5d6d97a6e4275e9014f24e226
PS C:\Users\tonyh\OneDrive\Work\2015-05-05-Docker> docker run -d --link $WEB_CID:insideweb dockerinaction/ch2_agent
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: “run” requires a minimum of 1 argument.
See ‘C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help’.

Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG…]

Run a command in a new container
PS C:\Users\tonyh\OneDrive\Work\2015-05-05-Docker> docker run -d --link 2278d27e0a2bdc1da0d6e77b8352d2146c7190a5d6d97a6e
4275e9014f24e226:insideweb dockerinaction/ch2_agent
2954fd42f4573f0d2b0090e3573d893675f927fc5cf6e660a0b3b2fdaf2a9d2e
PS C:\Users\tonyh\OneDrive\Work\2015-05-05-Docker>

Information

PS C:\Program Files\Docker\Docker\resources> .\DockerDebugInfo.ps1

OS Version

SystemDirectory : C:\WINDOWS\system32
Organization : Hewlett-Packard
BuildNumber : 10586
Version : 10.0.10586

Installed Files

Directory: C:\Program Files\Docker\Docker

Mode LastWriteTime Length Name


d----- 4/14/2016 9:47 PM resources
-a---- 4/14/2016 12:05 PM 47616 Bugsnag.dll
-a---- 4/14/2016 12:05 PM 16896 Docker.Application.dll
-a---- 4/14/2016 12:04 PM 420 Docker.Application.dll.config
-a---- 4/14/2016 12:05 PM 29184 Docker.Core.dll
-a---- 4/14/2016 12:04 PM 520 Docker.Core.dll.config
-a---- 4/14/2016 12:05 PM 485888 Docker.WPF.dll
-a---- 4/14/2016 12:05 PM 949824 DockerForWindows.exe
-a---- 4/14/2016 12:04 PM 520 DockerForWindows.exe.config
-a---- 4/14/2016 12:05 PM 47616 HockeyApp.dll
-a---- 4/14/2016 12:05 PM 73728 HockeyAppPCL.dll
-a---- 4/14/2016 12:05 PM 12800 InstallerCli.exe
-a---- 4/14/2016 12:04 PM 520 InstallerCli.exe.config
-a---- 7/8/2013 3:15 PM 45416 Microsoft.Web.Infrastructure.dll
-a---- 4/14/2016 12:05 PM 522752 Newtonsoft.Json.dll
-a---- 4/14/2016 12:05 PM 107696 Ookii.Dialogs.Wpf.dll
-a---- 4/14/2016 12:05 PM 3010560 System.Management.Automation.dll
-a---- 7/9/2013 11:04 AM 168616 System.Net.Http.Formatting.dll
-a---- 7/9/2013 11:04 AM 323240 System.Web.Http.dll
-a---- 7/9/2013 11:04 AM 507048 System.Web.Mvc.dll
-a---- 7/9/2013 11:05 AM 266944 System.Web.Razor.dll
-a---- 7/9/2013 11:05 AM 41152 System.Web.WebPages.Deployment.dll
-a---- 7/9/2013 11:05 AM 204480 System.Web.WebPages.dll
-a---- 7/9/2013 11:05 AM 39616 System.Web.WebPages.Razor.dll

Installed Resources

Directory: C:\Program Files\Docker\Docker\resources

Mode LastWriteTime Length Name


d----- 4/14/2016 9:47 PM bin
d----- 4/14/2016 9:47 PM qemu-img
-a---- 4/14/2016 12:05 PM 5899776 com.docker.agent.exe
-a---- 4/14/2016 12:05 PM 12083712 com.docker.proxy.exe
-a---- 4/14/2016 12:04 PM 3302 DockerDebugInfo.ps1
-a---- 4/14/2016 12:05 PM 19216 LICENSE.rtf
-a---- 4/14/2016 12:04 PM 72056832 mobylinux.iso
-a---- 4/14/2016 12:04 PM 14732 MobyLinux.ps1
-a---- 4/14/2016 12:04 PM 454110 OSS-LICENCE.rtf
-a---- 4/14/2016 12:05 PM 40 sha1
-a---- 4/14/2016 12:05 PM 4 UpdateChannel

Get-VMHost

Get-Process

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id SI ProcessName


146       8     2052       7344    70            7408   0 aesm_service
350      17     4924      16168    99     1.28   8856   1 Amazon Music Helper
193      18     3196      10672   118            3384   0 AppleMobileDeviceService
604      27    19748      32036 ...34    22.75  13840   1 ApplicationFrameHost
717      20    34296      40140 ...80   635.78  16448   0 audiodg
359      17     4924      17544 ...57     0.17  13672   1 browser_broker
215      19     7000      12556 34943     5.28  10608   1 com.docker.proxy
113       8     1384       6120 ...33            1344   1 conhost
 89       6     1108       4648 ...11            2540   0 conhost
154      12     6412      11496 ...73 1,042.64   6160   1 conhost
 88       6     1068       4512 ...10            9144   0 conhost
115       9     1624       6612 ...36     0.77   9256   1 conhost
 88       7     1356       4904 ...28     0.00  10632   1 conhost
154      11     4932      10916 ...46     3.70  12572   1 conhost
162      12     5216      11640 ...47     0.11  17560   1 conhost
165      12     2084       1840   105     1.78   3640   1 CoolSense
742      32    14492      31120   389     7.91  15792   1 CSISYNCCLIENT
469      18     1344       4024 ...04             672   0 csrss
623      24     2372       7996 ...42             796   1 csrss
418      18     7184      14268 ...22            2828   0 dasHost
202      13     5632      16040 ...01     0.14  15436   1 DataExchangeHost
135       8     1528       7820 ...91            7656   0 dllhost
213      12     2768      14836 ...70     0.22  11340   1 dllhost
138       8     1780       9752 ...23           19280   0 dllhost
147      10    14284      22304 34976   310.03  10828   1 docker
819      65   151044      83356   797    16.92   9544   1 DockerForWindows
914      60    67768      79392 ...23            1032   1 dwm
 82       6     1156       3856    74    87.36   2956   1 esif_assist_64
130       7     1596       5736    64            2920   0 esif_uf
297      15     4624      12100   105            2032   0 EvtEng

3147 147 66924 130564 …10 1,408.25 5024 1 explorer
34 7 10864 5876 …24 6840 1 fontdrvhost
244 14 3768 11296 99 3376 0 GfExperienceService
122 9 1456 812 57 7184 0 GoogleCrashHandler
114 8 1344 608 63 7488 0 GoogleCrashHandler64
285 18 3640 22116 …04 4.27 16752 1 HelpPane
172 10 1720 8036 67 15196 0 hpqwmiex
70 6 976 4372 33 1712 0 hpservice
435 38 37776 32820 614 14524 0 HPSupportSolutionsFrameworkService
113 7 1108 5080 52 3348 0 HPWMISVC
347 28 32312 36996 219 13796 0 IAStorDataMgrSvc
87 6 844 4264 32 1364 0 ibtsiva
0 0 0 4 0 0 0 Idle
159 9 1612 7516 46 1600 0 igfxCUIService
194 14 3820 12160 111 2.17 7576 1 igfxEM
131 11 2248 8412 66 1.19 7468 1 igfxHK
128 9 1528 6056 42 2332 0 IntelCpHeciSvc
124 8 2124 7000 48 7216 0 iPodService
102 9 1120 5392 32 9552 0 jhi_service
118 9 1280 6144 78 0.09 9164 1 jusched
1640 23 9680 18688 …05 948 0 lsass
143 14 1664 5676 32 2744 0 mDNSResponder
968 61 37536 82524 …97 70.55 13084 1 MicrosoftEdge
807 62 56204 90144 …95 25.80 972 1 MicrosoftEdgeCP
810 57 52892 83196 …82 30.47 12020 1 MicrosoftEdgeCP
906 113 173740 199592 …17 80.39 15396 1 MicrosoftEdgeCP
262 14 5272 15772 …62 12.83 6628 1 NetworkUXBroker
944 49 23100 9764 311 35.41 2864 1 nsbu
2932 73 60900 14744 390 3240 0 nsbu
321 21 14344 18488 171 8.11 1324 1 NvBackend
251 14 3460 9056 66 3132 0 NvNetworkService
481 34 7692 13656 149 5244 0 NvStreamNetworkService
206 13 2520 9600 76 3104 0 NvStreamService
453 26 7604 16888 158 4248 1 NvStreamUserAgent
169 15 3148 11516 128 0.22 2204 1 nvtray
177 9 2340 8692 75 1248 0 nvvsvc
372 22 8036 21976 180 1748 1 nvvsvc
298 19 8768 20908 164 1720 1 nvxdsync
724 26 29576 30168 217 3696 0 OfficeClickToRun
821 51 277320 219060 607 …66.78 8832 1 OneDrive
1167 50 62264 88892 500 75.83 7836 1 ONENOTE
152 11 2360 2540 84 0.28 14208 1 ONENOTEM
118 10 2088 6696 34 8768 0 openvpn
662 48 37716 40676 211 46.20 8872 1 Plex Media Server
363 51 7000 12308 115 75.36 12580 1 PlexDlnaServer
2383 21 30240 10400 144 10.63 6672 1 PlexScriptHost
514 30 61804 62428 …11 4.20 14220 1 powershell
497 28 67064 45752 …78 1.33 14320 1 powershell
655 37 125628 144072 …20 2.97 18936 1 powershell
195 26 25968 14192 522 5808 0 PresentationFontCache
262 14 5784 12720 117 2092 1 RAVBg64
130 8 1620 7864 75 3408 0 RegSrvc
309 18 9572 17600 …06 1.11 13392 1 RemindersServer
111 7 1200 5712 58 3424 0 RichVideo64
182 10 1832 7544 74 1956 0 RtkAudioService64
417 16 7320 13428 130 0.92 8712 1 RtkNGUI64
7029 942 3848392 1834328 …91 …18.11 3260 1 RuntimeBroker
667 57 28776 28492 …24 10076 0 SearchIndexer
1239 130 98920 172812 …20 13.31 2576 1 SearchUI
392 9 3504 6364 …73 940 0 services
528 35 16172 17620 …34 27.05 8200 1 SettingSyncHost
876 47 58544 115228 …90 493.25 11960 1 ShellExperienceHost
497 14 6480 22892 …57 9.73 1488 1 sihost
1093 51 20440 17600 245 3.78 3116 1 SkypeHost
49 3 368 980 …58 452 0 smss
371 25 29132 31272 …30 69.89 15140 1 SpeechRuntime
523 29 8728 17652 …58 2256 0 spoolsv
809 70 69028 97588 348 76.38 9920 1 Steam
216 14 23836 11056 95 9228 0 SteamService
658 29 16520 46528 264 4.08 9428 1 steamwebhelper
453 27 62872 91628 311 78.80 9564 1 steamwebhelper
376 23 27888 29816 231 0.53 16344 1 steamwebhelper
945 16 9644 14060 …98 8 0 svchost
864 22 8964 20168 …37 336 0 svchost
517 33 17424 34228 …91 968 0 svchost
2144 79 24324 52116 …83 1124 0 svchost
992 50 141672 142960 …98 1148 0 svchost
1029 57 13832 31908 …03 1264 0 svchost
1111 37 19080 31216 …06 1272 0 svchost
630 60 23424 30672 …11 1280 0 svchost
433 130 4396 11328 …17 1288 0 svchost
688 47 10992 21204 …89 1904 0 svchost
132 11 3796 7448 …97 3048 0 svchost
121 9 1460 6132 …83 3224 0 svchost
176 13 3528 46952 137 3232 0 svchost
65 6 904 3708 …77 3248 0 svchost
77 6 1000 4036 …78 3416 0 svchost
156 10 2028 7712 …00 3476 0 svchost
781 39 20684 49964 …85 73.59 3612 1 svchost
262 28 7348 20092 …60 3720 0 svchost
209 14 2872 9240 …10 5012 0 svchost
488 16 6476 18716 137 11.27 1320 1 SynTPEnh
197 5 904 3640 22 3448 0 SynTPEnhService
57 6 820 4176 47 0.06 6304 1 SynTPHelper
2618 0 1532 469700 486 4 0 System
487 28 12140 34948 …70 0.33 3184 1 SystemSettings
244 15 4188 17644 …63 5.81 15156 1 SystemSettingsBroker
278 14 2748 12436 …58 28.47 8120 1 TabTip
59 6 1080 3840 105 0.02 8188 1 TabTip32
430 164 40324 50668 …56 8.38 3168 1 taskhostw
128 8 1604 6632 …10 19292 0 taskhostw
110 6 1528 5984 …83 4228 0 unsecapp
704 43 95904 120116 346 21.20 14032 1 Uplay
223 22 38876 47748 244 0.84 1228 1 UplayWebCore
390 18 8020 19560 260 0.16 10476 1 Video.UI
609 25 17480 25340 …30 3944 0 vmms
376 19 36284 16032 …59 9852 0 vmwp
323 28 19364 33180 175 3.25 8408 1 vpn-unlimited
169 15 2172 8976 94 3896 0 vpn-unlimited-daemon
87 8 964 4292 …96 780 0 wininit
209 9 2080 9084 …09 860 1 winlogon
365 18 4360 14256 …52 2380 0 wlanext
394 19 6076 16192 …48 4852 0 WmiPrvSE
295 14 7320 15076 …10 15332 0 WmiPrvSE
334 9 1668 6560 …97 2848 0 WUDFHost
363 17 25244 13652 …60 2940 0 WUDFHost
307 22 4312 2792 116 6.59 4536 1 YouCamService6
297 18 5036 15600 118 3728 0 ZeroConfigService

Services

Image Name PID Services
========================= ======== ============================================
svchost.exe 336 BrokerInfrastructure, DcomLaunch, LSM,
PlugPlay, Power, SystemEventsBroker
svchost.exe 8 RpcEptMapper, RpcSs
svchost.exe 1124 Appinfo, BITS, Browser, DoSvc, IKEEXT,
iphlpsvc, LanmanServer, lfsvc, ProfSvc,
Schedule, SENS, ShellHWDetection, Themes,
UserManager, Winmgmt, wlidsvc
svchost.exe 1148 AudioEndpointBuilder,
DeviceAssociationService, HvHost,
NcbService, Netman, PcaSvc, SensorService,
SysMain, TabletInputService, TrkWks,
WdiSystemHost, WlanSvc, wudfsvc
svchost.exe 1264 bthserv, EventSystem, fdPHost, FontCache,
LicenseManager, netprofm, nsi,
WdiServiceHost, WinHttpAutoProxySvc
svchost.exe 1272 Audiosrv, Dhcp, EventLog,
HomeGroupProvider, lmhosts, Wcmsvc, wscsvc
svchost.exe 1280 BFE, CoreMessagingRegistrar, DPS, MpsSvc,
NcdAutoSetup
svchost.exe 1288 BthHFSrv, FDResPub, SSDPSRV, TimeBroker
svchost.exe 1904 CryptSvc, Dnscache, LanmanWorkstation,
NlaSvc
svchost.exe 968 DiagTrack
svchost.exe 3048 AppHostSvc
svchost.exe 3232 hpqcxs08, hpqddsvc
svchost.exe 3248 Net Driver HPZ12
svchost.exe 3416 Pml Driver HPZ12
svchost.exe 3476 stisvc
svchost.exe 3720 StateRepository, tiledatamodelsvc
svchost.exe 5012 HPSLPSVC
svchost.exe 3224 PolicyAgent
svchost.exe 3612 N/A

Get-VM

Get-VMComPort

Get-VMDvdDrive

Get-VMIntegrationService

Get-VMMemory

Get-VMProcessor

Get-VMScsiController

Get-VMSecurity

Get-VMSwitch

Get-VMSwitchExtension
Get-VMNetworkAdapter

Get-NetNAT

Name : DockerNAT
ExternalIPInterfaceAddressPrefix :
InternalIPInterfaceAddressPrefix : 10.0.75.0/24
IcmpQueryTimeout : 30
TcpEstablishedConnectionTimeout : 1800
TcpTransientConnectionTimeout : 120
TcpFilteringBehavior : AddressDependentFiltering
UdpFilteringBehavior : AddressDependentFiltering
UdpIdleSessionTimeout : 120
UdpInboundRefresh : False
Store : Local
Active : True

netstat -abno
The requested operation requires elevation.
netstat -rs

IPv4 Statistics

Packets Received = 2844291
Received Header Errors = 0
Received Address Errors = 4
Datagrams Forwarded = 0
Unknown Protocols Received = 0
Received Packets Discarded = 30264
Received Packets Delivered = 3580536
Output Requests = 3512976
Routing Discards = 0
Discarded Output Packets = 84
Output Packet No Route = 0
Reassembly Required = 0
Reassembly Successful = 0
Reassembly Failures = 0
Datagrams Successfully Fragmented = 0
Datagrams Failing Fragmentation = 0
Fragments Created = 0

IPv6 Statistics

Packets Received = 11340
Received Header Errors = 0
Received Address Errors = 6
Datagrams Forwarded = 0
Unknown Protocols Received = 0
Received Packets Discarded = 1830
Received Packets Delivered = 11451
Output Requests = 6504
Routing Discards = 0
Discarded Output Packets = 20
Output Packet No Route = 6
Reassembly Required = 0
Reassembly Successful = 0
Reassembly Failures = 0
Datagrams Successfully Fragmented = 0
Datagrams Failing Fragmentation = 0
Fragments Created = 0

ICMPv4 Statistics

                        Received    Sent

Messages 47 794
Errors 0 0
Destination Unreachable 0 739
Time Exceeded 0 0
Parameter Problems 0 0
Source Quenches 0 0
Redirects 0 0
Echo Replies 0 47
Echos 47 8
Timestamps 0 0
Timestamp Replies 0 0
Address Masks 0 0
Address Mask Replies 0 0
Router Solicitations 0 0
Router Advertisements 0 0

ICMPv6 Statistics

                        Received    Sent

Messages 44 99
Errors 0 0
Destination Unreachable 9 9
Packet Too Big 0 0
Time Exceeded 0 0
Parameter Problems 0 0
Echos 0 0
Echo Replies 0 0
MLD Queries 0 0
MLD Reports 0 0
MLD Dones 0 0
Router Solicitations 0 9
Router Advertisements 0 0
Neighbor Solicitations 12 66
Neighbor Advertisements 23 15
Redirects 0 0
Router Renumberings 0 0

TCP Statistics for IPv4

Active Opens = 87979
Passive Opens = 79429
Failed Connection Attempts = 120
Reset Connections = 2036
Current Connections = 59
Segments Received = 1939155
Segments Sent = 1960923
Segments Retransmitted = 17600

TCP Statistics for IPv6

Active Opens = 150
Passive Opens = 52
Failed Connection Attempts = 28
Reset Connections = 14
Current Connections = 0
Segments Received = 3344
Segments Sent = 2272
Segments Retransmitted = 61

UDP Statistics for IPv4

Datagrams Received = 1677351
No Ports = 30173
Receive Errors = 17
Datagrams Sent = 1529373

UDP Statistics for IPv6

Datagrams Received = 9842
No Ports = 1829
Receive Errors = 1
Datagrams Sent = 4461

Interface List
12…00 15 5d 00 00 00 …Hyper-V Virtual Ethernet Adapter
11…e0 94 67 65 6a df …Intel(R) Dual Band Wireless-AC 3165
16…e0 94 67 65 6a e0 …Microsoft Wi-Fi Direct Virtual Adapter
13…dc 4a 3e de 6a 15 …Realtek PCIe FE Family Controller
8…00 ff 2e 9b 1f 44 …TAP-Windows Adapter V9
10…e0 94 67 65 6a e3 …Bluetooth Device (Personal Area Network)
1…Software Loopback Interface 1
17…00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter
2…00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #2
7…00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #3

IPv4 Route Table

Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.1.254 192.168.1.220 20
0.0.0.0 128.0.0.0 10.200.10.77 10.200.10.78 30
10.0.75.0 255.255.255.0 On-link 10.0.75.1 261
10.0.75.1 255.255.255.255 On-link 10.0.75.1 261
10.0.75.255 255.255.255.255 On-link 10.0.75.1 261
10.200.0.1 255.255.255.255 10.200.10.77 10.200.10.78 30
10.200.10.76 255.255.255.252 On-link 10.200.10.78 286
10.200.10.78 255.255.255.255 On-link 10.200.10.78 286
10.200.10.79 255.255.255.255 On-link 10.200.10.78 286
127.0.0.0 255.0.0.0 On-link 127.0.0.1 306
127.0.0.1 255.255.255.255 On-link 127.0.0.1 306
127.255.255.255 255.255.255.255 On-link 127.0.0.1 306
128.0.0.0 128.0.0.0 10.200.10.77 10.200.10.78 30
192.168.1.0 255.255.255.0 On-link 192.168.1.220 276
192.168.1.220 255.255.255.255 On-link 192.168.1.220 276
192.168.1.255 255.255.255.255 On-link 192.168.1.220 276
209.58.130.135 255.255.255.255 192.168.1.254 192.168.1.220 20
224.0.0.0 240.0.0.0 On-link 127.0.0.1 306
224.0.0.0 240.0.0.0 On-link 10.200.10.78 286
224.0.0.0 240.0.0.0 On-link 192.168.1.220 276
224.0.0.0 240.0.0.0 On-link 10.0.75.1 261
255.255.255.255 255.255.255.255 On-link 127.0.0.1 306
255.255.255.255 255.255.255.255 On-link 10.200.10.78 286
255.255.255.255 255.255.255.255 On-link 192.168.1.220 276
255.255.255.255 255.255.255.255 On-link 10.0.75.1 261

Persistent Routes:
None

IPv6 Route Table

Active Routes:
If Metric Network Destination Gateway
1 306 ::1/128 On-link
8 286 fe80::/64 On-link
13 276 fe80::/64 On-link
12 261 fe80::/64 On-link
13 276 fe80::89c3:b6d6:3f2e:5b1f/128
On-link
8 286 fe80::95b1:ebfb:ddcc:a15a/128
On-link
12 261 fe80::a429:7dec:d00d:eec0/128
On-link
1 306 ff00::/8 On-link
8 286 ff00::/8 On-link
13 276 ff00::/8 On-link
12 261 ff00::/8 On-link

Persistent Routes:
None

net share
New connections will be remembered.

There are no entries in the list.

Steps to reproduce the behavior

  1. Execute: $WEB_CID = docker run -d nginx
  2. Execute: docker run -d --link $WEB_CID:insideweb dockerinaction/ch2_agent
  3. Get error.

@solidstrider I think you need to escape the colon (with a backtick). This works for me:

$WEB_CID = docker run -d nginx
docker run -d --link $WEB_CID`:nginx debian

Great! That backtick did the trick!! Thank you Friism!