nerdctl error parsing configuration while trying to run image - containerd

I am new to containerD and specially to nerdctl cli so may be there's an easy way to do/debug that ? Most of the tutorial is about to run it on Linux but I am running on Windows
I created a Docker image named: image1, pushed it to Google Artifact Registry, pulled it by nerdctl - everything is OK. But when I try to actually run it I get an error:
nerdctl run -it europe-west6-docker.pkg.dev/project/build/image1 cmd --debug-full
error is:
time="2022-09-18T14:23:07+03:00" level=fatal msg="error parsing configuration: invalid character ':' after array element"
I am running on Windows and using Windows images in Docker containers.
Here is nerdctl inspect command:
[
{
"Id": "sha256:dfeccc2743d671b9582695615e6fd5e0b9bb18797ec931bbc8d50146679b37f3",
"RepoTags": [
"europe-west6-docker.pkg.dev/project/build/image1:latest"
],
"RepoDigests": [
"europe-west6-docker.pkg.dev/project/build/image1#sha256:11ac1c4704aa96c28c304b3b81a509e2211295087382fe37c10a8f75c1c2f3f6"
],
"Comment": "",
"Created": "2022-09-18T09:04:30.0283571Z",
"Author": "",
"Config": {
"AttachStdin": false,
"ExposedPorts": {
"9997/tcp": {},
"9998/tcp": {},
"9999/tcp": {}
},
"Env": [
"NODE_VERSION=16.14.1"
],
"Cmd": [
"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -command Start-Process -NoNewWindow -FilePath 'npm' -ArgumentList 'run', 'start:parse1';"
],
"WorkingDir": "C:\\image1"
},
"Architecture": "amd64",
"Os": "windows",
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:d6fdd6832d95a5f537e0e7d87f2613ea9741ad9c20438b9d5a2697a883c4cd96",
"sha256:1b45f33405d020d92048301e0e63a2c5e7cc408faeba3fd7bf931e980ae36ba3",
"sha256:39246581a1ae4c39a00bb005ab50be9640e373cf1ff3ca6065398fa4dd837703",
"sha256:a530cfbfa1ac6ff39426ab75ab39a919fb4ca5de2af28d436fe8c39ee154c2fa",
"sha256:f8cca1943cd8f5fa45993438d0c9b0d2eb686e4e4bad485b63c3b16c93b16e69",
"sha256:527be45c47550e9d6dd7f2b36a28ae25794523ca915a9ebd8445c9c463eaf034",
"sha256:4565236123b2abdc4f87f0eb03b3ad92a51dc3d1437db79b45261178b8cd7b31",
"sha256:f8a03c5f20c54a596754bcdbd9882fa1540cbc627ad484888b554e3a78905e45",
"sha256:a5b070a25e50ff7f67bba1a12f9dee00bb56f1967f8b82d53323bbc2ee9671ec",
"sha256:938c1ecb24476120bab6bbb263b0e3e8e667cc1ffd3dc906ed6ebf1fd55f894c",
"sha256:8b89aca5a6000dd0880a78763f424000242ad5db7ea1daf1cf0f5770cd2a5888",
"sha256:6ef91cca0e7c2f0faf36daf27da25b1361d6e8c42254ee9aaac096e6b5fe2a47",
"sha256:9febc969f24df33757baa2761079efea9c3006e55d298554d20b52fb22c41137"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]
and here is Docker image:
# escape=`
FROM mcr.microsoft.com/windows/servercore:ltsc2019-amd64
SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"]
# Setting Windows culture will set time presentation to 24 format, short time presentation, etc...
RUN Set-Culture he-IL
# Install Nodejs
ENV NODE_VERSION 16.14.1
RUN Invoke-WebRequest $('https://nodejs.org/dist/v{0}/node-v{0}-win-x64.zip' -f $env:NODE_VERSION) -OutFile 'node.zip' -UseBasicParsing; `
Expand-Archive node.zip -DestinationPath 'C:\' ; `
Rename-Item -Path $('C:\node-v{0}-win-x64' -f $env:NODE_VERSION) -NewName 'C:\nodejs'; `
Remove-Item node.zip; `
$env:PATH = 'C:\nodejs;' -f $env:PATH ; `
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine);
WORKDIR /image1
# Copy whole folder because some 3rd party binaries are used
COPY . .
EXPOSE 9999
EXPOSE 9998
EXPOSE 9997
ENTRYPOINT [ ]
CMD Start-Process -NoNewWindow -FilePath 'npm' -ArgumentList 'run', 'start:parse1';

Related

Packer provisioners don't save installed packages

I have encountered an issue during provisioning with HashiCorp Packer for virtualbox-iso on Alpine Linux v3.16.
Provisioning script runs OK, and it logs that build has finished, however when I open the outputted ovf file in VirtualBox moved files and docker are not present.
I would be grateful for any advice.
I run packer build packer-virtualbox-alpine-governator.json
packer-virtualbox-alpine-governator.json file:
{
"variables": {
"password": "packer"
},
"builders": [
{
"type": "virtualbox-iso",
"memory": 8192,
"guest_os_type": "Other_64",
"iso_url": "https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/alpine-standard-3.16.0-x86_64.iso",
"iso_checksum": "file:https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/alpine-standard-3.16.0-x86_64.iso.sha256",
"ssh_username": "root",
"ssh_password": "{{user `password`}}",
"shutdown_command": "poweroff",
"hard_drive_interface": "sata",
"boot_command": [
"root<enter><wait>",
"setup-alpine<enter><wait>us<enter><wait>us<enter><wait><enter><wait><enter><wait><enter><wait><enter><wait5>{{user `password`}}<enter><wait>{{user `password`}}<enter><wait><enter><wait><enter><wait><enter><wait15><enter><wait>openssh<enter><wait>openssh-full<enter><wait5>test123<enter><wait5>test123<enter><wait><enter><wait><enter><wait>sda<enter><wait>sys<enter><wait>y<enter><wait30>",
"echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config<enter><wait>",
"/etc/init.d/sshd restart<enter><wait5>"
]
}
],
"provisioners": [
{
"type": "shell",
"inline": ["mkdir -p /opt/site/governator"]
},
{
"type": "file",
"source": "files/docker-compose.yaml",
"destination": "/opt/site/"
},
{
"type": "file",
"source": "files/governator.conf",
"destination": "/opt/site/governator/"
},
{
"type": "shell",
"scripts": [
"scripts/alpine/install-docker-on-alpine.sh"
]
}
]
}
./scritps/alpine/install-docker-on-alpine.sh
#! /bin/ash
cat > /etc/apk/repositories << EOF; $(echo)
https://dl-cdn.alpinelinux.org/alpine/v$(cut -d'.' -f1,2 /etc/alpine-release)/main/
https://dl-cdn.alpinelinux.org/alpine/v$(cut -d'.' -f1,2 /etc/alpine-release)/community/
https://dl-cdn.alpinelinux.org/alpine/edge/testing/
EOF
apk update
apk add docker
addgroup $USER docker
rc-update add docker boot
service docker start
apk add docker-compose
sync

Prevent Windows Terminal Title from changing

I am trying out Windows Terminal. I use bash and want the Windows Terminal Tab title to remain as cwd (which is initially set by bash) instead of changing since while using multiple tabs they become indistinguishable. If I run say npm run start in bash directly, the title (in title bar) remains as cwd but if I try to use it via Windows Terminal the tab title changes to npm which I don't want.
My .bashrc
if test -f /etc/profile.d/git-sdk.sh
then
TITLEPREFIX=SDK-${MSYSTEM#MINGW}
else
TITLEPREFIX=$MSYSTEM
fi
if test -f ~/.config/git/git-prompt.sh
then
. ~/.config/git/git-prompt.sh
else
# PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]' # set window title
# PS1='\[\e]0;\W\a\]\[\033]0;$PWD\007\]' # set window title (full path)
PS1='\[\e]0;\W\a\]' # set window title (only directory name)
PS1="$PS1"'\n' # new line
PS1="$PS1"'\[\033[32m\]' # change to green
PS1="$PS1"'\u ' # user#host<space>
# PS1="$PS1"'\[\033[35m\]' # change to purple
# PS1="$PS1"'$MSYSTEM ' # show MSYSTEM
PS1="$PS1"'\[\033[33m\]' # change to brownish yellow
PS1="$PS1"'\w' # current working directory
if test -z "$WINELOADERNOEXEC"
then
GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)"
COMPLETION_PATH="${GIT_EXEC_PATH%/libexec/git-core}"
COMPLETION_PATH="${COMPLETION_PATH%/lib/git-core}"
COMPLETION_PATH="$COMPLETION_PATH/share/git/completion"
if test -f "$COMPLETION_PATH/git-prompt.sh"
then
. "$COMPLETION_PATH/git-completion.bash"
. "$COMPLETION_PATH/git-prompt.sh"
PS1="$PS1"'\[\033[36m\]' # change color to cyan
PS1="$PS1"'`__git_ps1`' # bash function
fi
fi
PS1="$PS1"'\[\033[0m\]' # change color
PS1="$PS1"'\n' # new line
PS1="$PS1"'$ ' # prompt: always $
fi
MSYS2_PS1="$PS1" # for detection by MSYS2 SDK's bash.basrc
# Evaluate all user-specific Bash completion scripts (if any)
if test -z "$WINELOADERNOEXEC"
then
for c in "$HOME"/bash_completion.d/*.bash
do
# Handle absence of any scripts (or the folder) gracefully
test ! -f "$c" ||
. "$c"
done
fi
export PS1='${debian_chroot:+($debian_chroot)}\[\e]0;\W\a\]\[\033[01;32m\]\u \[\033[00m\]\[\033[01;00m\]\w\n$ '
# echo -ne '\033]0;New Title\a'
My Windows Terminal settings.json
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{00000000-0000-0000-ba54-000000000002}",
"copyOnSelect": false,
"copyFormatting": false,
"profiles": {
"defaults": {
"fontSize": 10
},
"list": [
{
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "Command Prompt",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"guid": "{00000000-0000-0000-ba54-000000000002}",
"commandline": "%PROGRAMFILES%/git/usr/bin/bash.exe -i -l",
"icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
"name": "Bash",
"startingDirectory": "%USERPROFILE%"
}
]
},
"schemes": [],
"actions": [
{ "command": { "action": "copy", "singleLine": false }, "keys": "ctrl+c" },
{ "command": "paste", "keys": "ctrl+v" },
{ "command": "find", "keys": "ctrl+shift+f" },
{
"command": {
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
}
]
}
How do I achieve this?
windows terminal has two tag to change this
"tabTitle": "yourtitle",
"suppressApplicationTitle": true
so in your case, maybe you can write like this
{
"guid": "{00000000-0000-0000-ba54-000000000002}",
"commandline": "%PROGRAMFILES%/git/usr/bin/bash.exe -i -l",
"icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
"name": "Bash",
"startingDirectory": "%USERPROFILE%",
"tabTitle": "cwd",
"suppressApplicationTitle": true
}

vscode tasks.json shell script doesn't work with arguments

I can't pass arguments to shell script in task.
I work in VSCode 1.36.0 in Ubuntu 18.04. tasks.json version 2.0.0
There is a simple task in tasks.json file:
{
"label": "cross-deploy_2",
"type": "shell",
"options": {
"cwd": "/home/${env:USERNAME}/osr-renesas/"
},
"command": ". ./cross-deploy_2.sh",
"problemMatcher": [
"$gcc"
]
},
And here is the script cross-deploy_2.sh:
ip=$1
execution_file=$2
echo $ip
echo $execution_file
. sources/poky/oe-init-build-env
devtool build glv-get-started
I need to run it from source in order to save environment variables. So in the previous example I don't see echo, but except this script runs properly.
If I add args, like this
{
"label": "cross-deploy_2",
"type": "shell",
"options": {
"cwd": "/home/${env:USERNAME}/osr-renesas/"
},
"command": ". ./cross-deploy_2.sh",
"args": [
"10.15.11.1",
"glv-get-started",
],
"problemMatcher": [
"$gcc"
]
},
The task doesn't work. And this is the output in the terminal
> Executing task: '. ./cross-deploy_2.sh' 10.15.11.1 glv-get-started <
/bin/bash: . ./cross-deploy_2.sh: No such file or directory
The terminal process command '/bin/bash -c ''. ./cross-deploy_2.sh'
10.15.11.1 glv-get-started'' failed to launch (exit code: 127)
Terminal will be reused by tasks, press any key to close it.
Please help me to run script with arguments
Thanks a lot in advance

Windows CloudFormation Script, MetaData commands are not running

Below is my CloudFormation template for creating a windows EC2 instance with Java and Tomcat installed on it. However, the nothing from the MetaData is being executed. I login to the created EC2 instance, and none of the specified folders in the metadata can be found. What is my CloudFormation script missing?
Thank you
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Script to create Windows AMI",
"Metadata": {
"AWS::CloudFormation::Designer": {
"94153bdc-589b-4aa8-b859-5e84a1051a50": {
"size": {
"width": 60,
"height": 60
},
"position": {
"x": 280,
"y": 110
},
"z": 1,
"embeds": []
}
}
},
"Parameters": {},
"Rules": {},
"Mappings": {},
"Resources": {
"JavaTomcatEC2Instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": "ami-06b19063",
"InstanceType": "t2.micro",
"KeyName": "WindowsTest"
},
"Metadata": {
"AWS::CloudFormation::Init": {
"configSets": {
"config": [
"setup"
]
},
"setup": {
"Install-Java-Tomcat-set-env-variables-paths": {
"files": {
"c:\\cfn\\modules\\jdk-8u151-windows-x64.exe": {
"source": "https://s3.amazonaws.com/windows-ami-software/jdk-8u151-windows-x64.exe"
},
"c:\\cfn\\modules\\apache-tomcat-8.5.23.exe": {
"source": "https://s3.amazonaws.com/windows-ami-software/apache-tomcat-8.5.23.exe"
},
"c:\\cfn\\scripts\\Install-Java-JDK.ps1": {
"content": {
"Fn::Join": [
"",
[
"Set-Location C:\\cfn\\modules;",
".\\jdk-8u151-windows-x64.exe /s ADDLOCAL=\"ToolsFeature,SourceFeature,PublicjreFeature\"",
"\n"
]
]
}
},
"c:\\cfn\\scripts\\Install-Tomcat8.ps1": {
"content": {
"Fn::Join": [
"",
[
"Set-Location C:\\cfn\\modules;",
".\\apache-tomcat-8.5.23.exe /S",
"\n"
]
]
}
},
"c:\\cfn\\scripts\\Set-Java-Tomcat8-Paths-Homes.ps1": {
"content": {
"Fn::Join": [
"",
[
"$oldPath=(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\Environment' -Name PATH).Path;",
"$addedFolder = 'C:\\Program Files\\Java\\jdk1.8.0_151\\bin; C:\\Program Files\\Apache Software Foundation\\Tomcat 8.5\\bin';",
"$newPath = $oldPath +';'+$addedFolder;",
"Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\Environment' -Name PATH -Value $newPath ;",
"[Environment]::SetEnvironmentVariable('CATALINA_HOME', 'C:\\Program Files\\Apache Software Foundation\\Tomcat 8.5\\', 'Machine');",
"[Environment]::SetEnvironmentVariable('JAVA_HOME', 'C:\\Program Files\\Java\\jdk1.8.0_151\\', 'Machine');",
"Restart-Computer -Force;",
"\n"
]
]
}
},
"c:\\cfn\\scripts\\Install-Tomcat8-Service.ps1": {
"content": {
"Fn::Join": [
"",
[
"Set-Location 'C:\\Program Files\\Apache Software Foundation\\Tomcat 8.5\\bin';",
".\\service.bat install;",
"Set-Service Tomcat8 -StartupType Automatic;",
"Start-Service Tomcat8;",
"\n"
]
]
}
}
},
"commands": {
"a-Install-Java-JDK": {
"command": "powershell.exe -ExecutionPolicy RemoteSigned -Command c:\\cfn\\scripts\\Install-Java-JDK.ps1",
"waitAfterCompletion": "30"
},
"b-Install-Tomcat8": {
"command": "powershell.exe -ExecutionPolicy RemoteSigned -Command c:\\cfn\\scripts\\Install-Tomcat8.ps1",
"waitAfterCompletion": "30"
},
"c-Set-Java-Tomcat8-Paths-Homes": {
"command": "powershell.exe -ExecutionPolicy RemoteSigned -Command c:\\cfn\\scripts\\Set-Java-Tomcat8-Paths-Homes.ps1",
"waitAfterCompletion": "forever"
},
"d-Install-Tomcat8-Service": {
"command": "powershell.exe -ExecutionPolicy RemoteSigned -Command c:\\cfn\\scripts\\Install-Tomcat8-Service.ps1",
"waitAfterCompletion": "30"
}
}
}
}
},
"AWS::CloudFormation::Designer": {
"id": "94153bdc-589b-4aa8-b859-5e84a1051a50"
}
}
}
}
}
There are 2 things you need to check:
Check if those scripts are getting created on location C:\cfn\scripts
--IF not then check where is the issue
If these scripts are created there, then call separately the step "commands" in configSets (line no. 33-34). I suspect that is the problem where the actual scripts are not getting called.
Instead of using "setup" block, try something like this. This is how I have been using.
"Metadata": {
"AWS::CloudFormation::Init": {
"config": {
"files": {
"c:\\cfn\\modules\\jdk-8u151-windows-x64.exe": {
"source": "https://s3.amazonaws.com/windows-ami-software/jdk-8u151-windows-x64.exe"
},
"c:\\cfn\\modules\\apache-tomcat-8.5.23.exe": {
"source": "https://s3.amazonaws.com/windows-ami-software/apache-tomcat-8.5.23.exe"
},
"c:\\cfn\\scripts\\Install-Java-JDK.ps1": {
"content": {
"Fn::Join": [
"",
[
"Set-Location C:\\cfn\\modules;",
".\\jdk-8u151-windows-x64.exe /s ADDLOCAL=\"ToolsFeature,SourceFeature,PublicjreFeature\"",
"\n"
]
]
}
},
"c:\\cfn\\scripts\\Install-Tomcat8.ps1": {
"content": {
"Fn::Join": [
"",
[
"Set-Location C:\\cfn\\modules;",
".\\apache-tomcat-8.5.23.exe /S",
"\n"
]
]
}
},
"c:\\cfn\\scripts\\Set-Java-Tomcat8-Paths-Homes.ps1": {
"content": {
"Fn::Join": [
"",
[
"$oldPath=(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\Environment' -Name PATH).Path;",
"$addedFolder = 'C:\\Program Files\\Java\\jdk1.8.0_151\\bin; C:\\Program Files\\Apache Software Foundation\\Tomcat 8.5\\bin';",
"$newPath = $oldPath +';'+$addedFolder;",
"Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\Environment' -Name PATH -Value $newPath ;",
"[Environment]::SetEnvironmentVariable('CATALINA_HOME', 'C:\\Program Files\\Apache Software Foundation\\Tomcat 8.5\\', 'Machine');",
"[Environment]::SetEnvironmentVariable('JAVA_HOME', 'C:\\Program Files\\Java\\jdk1.8.0_151\\', 'Machine');",
"Restart-Computer -Force;",
"\n"
]
]
}
},
"c:\\cfn\\scripts\\Install-Tomcat8-Service.ps1": {
"content": {
"Fn::Join": [
"",
[
"Set-Location 'C:\\Program Files\\Apache Software Foundation\\Tomcat 8.5\\bin';",
".\\service.bat install;",
"Set-Service Tomcat8 -StartupType Automatic;",
"Start-Service Tomcat8;",
"\n"
]
]
}
}
},
"commands": {
"a-Install-Java-JDK": {
"command": "powershell.exe -ExecutionPolicy RemoteSigned -Command c:\\cfn\\scripts\\Install-Java-JDK.ps1",
"waitAfterCompletion": "30"
},
"b-Install-Tomcat8": {
"command": "powershell.exe -ExecutionPolicy RemoteSigned -Command c:\\cfn\\scripts\\Install-Tomcat8.ps1",
"waitAfterCompletion": "30"
},
"c-Set-Java-Tomcat8-Paths-Homes": {
"command": "powershell.exe -ExecutionPolicy RemoteSigned -Command c:\\cfn\\scripts\\Set-Java-Tomcat8-Paths-Homes.ps1",
"waitAfterCompletion": "forever"
},
"d-Install-Tomcat8-Service": {
"command": "powershell.exe -ExecutionPolicy RemoteSigned -Command c:\\cfn\\scripts\\Install-Tomcat8-Service.ps1",
"waitAfterCompletion": "30"
}
}
}
}
}
Super old... but anywho!
cfn-init is never called. Typically this will be done once via UserData
UserData:
Fn::Base64:
!Sub |
<PowerShell>
cfn-init.exe -v -s ${AWS::StackName} -r <resourceref> --configsets MyConfigSet --region ${AWS::Region}
</PowerShell>
Then within your init you'd also configure the cfn-hup service to monitor a couple configuration files.
AWS::CloudFormation::Init:
configSets:
MyConfigSet:
- configureCfn
configureCfn:
files:
c:\\cfn\\cfn-hup.conf:
content: !Sub |
[main]
stack=${AWS::StackName}
region=${AWS::Region}
c:\\cfn\\hooks.d\\cfn-auto-reloader.conf:
content: !Sub |
[cfn-auto-reloader-hook]
triggers=post.update
path=Resources.UiPathRobot.Metadata.AWS::CloudFormation::Init
action=cfn-init.exe -v -s ${AWS::StackName} -r <resourceref> --configsets MyConfigSet --region ${AWS::Region}
services:
windows:
cfn-hup:
enabled: true
ensureRunning: true
files:
- c:\cfn\cfn-hup.conf
- c:\cfn\hook.d\cfn-auto-reloader.conf
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-windows-stacks-bootstrapping.html

Docker disconnect all containers from docker network

I have docker network "my_network". I want to remove this docker network with docker network rm my_network. Before it I should disconnect all my containers from this network. I can use docker network inspect and get output like
[
{
"Name": "my_network",
"Id": "aaaaaa",
"Scope": "some_value",
"Driver": "another_value",
"EnableIPv6": bool_value,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "10.0.0.0/1"
}
]
},
"Internal": false,
"Containers": {
"bbb": {
"Name": "my_container_1",
"EndpointID": "ENDPOITID1",
"MacAddress": "MacAddress1",
"IPv4Address": "0.0.0.0/1",
"IPv6Address": ""
},
"ccc": {
"Name": "my_container_2",
"EndpointID": "ENDPOINTID2",
"MacAddress": "MacAddress2",
"IPv4Address": "0.0.0.0/2",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
It is okay to manual disconnect if I have only several containers but if I have 50 containers I have problem.
How can I disconnect all containers from this network with single or several command?
docker network inspect has a format option.
That means you can list all Container names with:
docker network inspect -f '{{range .Containers}}{{.Name}}{{end}}' network_name
That should then be easy, by script, to read each name and call docker network disconnect.
wwerner proposes below in the comments the following command:
for i in ` docker network inspect -f '{{range .Containers}}{{.Name}} {{end}}' network_name`; do docker network disconnect -f network_name $i; done;
In multiple line for readability:
for i in ` docker network inspect -f '{{range .Containers}}{{.Name}} {{end}}' network_name`;\
do \
docker network disconnect -f network_name $i; \
done;
Adding:
Note that there is a space in the format as opposed to the answer to split the names by a space.

Resources