Learn how to create a Docker container and run it using command prompt.
The docker run command is among the first and most crucial ones that new Docker users are taught. It should not be surprising as its main purpose is to create and execute/run a docker containers.
There are many ways to run a docker container, however I like using the command prompt route it has lots of flexility using the CLI (command line interface) flags. In this video, I will be demonstrating the basic syntax of how you use the interaction (-i), tty (-t), change container name (–name) and allow admin access to your container (–cap-add=NET_ADMIN) using these docker flags.
Commands used in this video
1) Enable interaction (-i).
docker run -i ubuntu:latest
2) Enable tty (-t).
docker run -it ubuntu:latest
3) Custom container name (–name XynetContainer).
docker run -it --name XynetContainer ubuntu:latest
4) Allow admin access to container (–cap-add=NET_ADMIN)
docker run -it --name XynetContainer --cap-add=NET_ADMIN ubuntu:latest
If you are stilling having, try restarting the Docker service with the following commands.
systemctl stop docker
systemctl stop docker.socket
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
systemctl start docker
systemctl start docker.socket