Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahmetozer/cna
Container Network Admin, Control or debug container network with the temporary container.
https://github.com/ahmetozer/cna
administration arp cna container docker linux network network-tools ping tracert traffic-monitoring
Last synced: 2 months ago
JSON representation
Container Network Admin, Control or debug container network with the temporary container.
- Host: GitHub
- URL: https://github.com/ahmetozer/cna
- Owner: ahmetozer
- License: apache-2.0
- Created: 2020-08-24T21:42:28.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-31T21:30:46.000Z (almost 3 years ago)
- Last Synced: 2023-03-10T18:38:46.794Z (almost 2 years ago)
- Topics: administration, arp, cna, container, docker, linux, network, network-tools, ping, tracert, traffic-monitoring
- Language: Shell
- Homepage: https://hub.docker.com/r/ahmetozer/cna
- Size: 26.4 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Network Tools for Containers
Distroless and rootless network tools in a container.
## Linux
Using for container host network
```bash
docker run -it --rm --network=host --cap-add=CAP_NET_BIND_SERVICE --cap-add=CAP_NET_RAW --cap-add=CAP_NET_ADMIN ghcr.io/ahmetozer/cna:latest
```Using for inside the Container Network
```bash
docker run -it --rm --privileged --net container:teredo-container ghcr.io/ahmetozer/cna:latest
```You can add bash function for more easy execution
```bash
# You can add to .bashrc
function cna {
container_name="$1" # This is your container to which is do you want to make a network inspect
shift 1
if [ -z "$container_name" ] || [ "$container_name" == "host" ]
then
docker run -it --rm --cap-add=CAP_NET_BIND_SERVICE --cap-add=CAP_NET_RAW --cap-add=CAP_NET_ADMIN --pid host --network host ghcr.io/ahmetozer/cna:latest $@
else
docker run -it --rm --cap-add=CAP_NET_BIND_SERVICE --cap-add=CAP_NET_RAW --cap-add=CAP_NET_ADMIN --pid container:$container_name --net container:$container_name ghcr.io/ahmetozer/cna:latest $@
fi
}_cna_completions() {
nettools=("ping" "traceroute" "tcpdump"
"iperf3" "nmap" "netcat" "curl" "ethtool" "socat" "ip"
"nslookup" "whois" "bash")
if [ ${#COMP_WORDS[@]} -lt 3 ]; then
local containers=($(docker ps -aq --no-trunc))
local names=($(docker inspect --format '{{.Name}}' "${containers[@]}"))
names=("${names[@]#/}")
names+=('host')
COMPREPLY=($(compgen -W "${names[*]}" "${COMP_WORDS[1]}"))
elif [ ${#COMP_WORDS[@]} -eq 3 ]; then
COMPREPLY=($(compgen -W "${nettools[*]}" "${COMP_WORDS[2]}"))
fi
}complete -F _cna_completions cna
```
```bash
#for run inside container
cna mycontainer
# run on host
cna# run with command
cna mycontainer ip a
# run with command on host
cna host tcpdump -n
```## Windows
You can use CNA in WSL2 backend docker
Add cna as DOSKEY on cmd.```cmd
DOSKEY cna=docker run -it --rm --privileged -e WSL=yes --network host -v /proc/:/proc2/ -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/ahmetozer/cna:latest /usr/bin/ENTRYPOINT.sh $*
```