how to run docker image with iptables support enabled? - docker

I have these two containers:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0d671dfac62b ubuntu "/bin/bash" 38 minutes ago Exited (0) 11 minutes ago firewall-test
c17081905d25 ubuntu "bash" 2 hours ago Exited (0) 2 hours ago mystifying_kalam
I would like to start the firewall-test container with a bash shell and this setting --cap-add=NET_ADMIN
The command i am trying does not work, it keep complaining about the latest version of this container...
sudo docker run --cap-add=NET_ADMIN -it firewall-test bash
Unable to find image 'firewall-test:latest' locally
docker: Error response from daemon: pull access denied for firewall-test, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
The firewall-test container is based on the ubuntu one under it in the list.
How can i run this container with net-admin support so i can play around with iptables?
Thanks

You are having trouble with the syntax here. The form is 'docker run [-OPTIONS] [IMAGE NAME] {commands if you use options like -it or an entrypoint}'.
In your case it would be "docker run --cap-add=NET_ADMIN -it [IMAGE NAME] bash". First be sure that you have a 'firewall-test' image already build/downloaded.
In case you're using a Dockerfile image based, first build it. Or if you are using an image from hub.docker on something like that be sure the name is correct.
Good luck

Related

docker container exist but does not run with container ID

I have created a container locally. Then, I run the following command:
docker ps -a
output is:
ONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
abc6f4d50931 airflow "/bin/zsh" 17 hours ago Exited (137) 21 minutes ago xenodochial_mclaren
Then I try to run the container with the following command, it create a new container with same IMAGE but different container ID instead opening the container with this image name which exist.
docker run -p 8080:8080 -it airflow /bin/zsh/
The output of docker images command is:
REPOSITORY TAG IMAGE ID CREATED SIZE
airflow airflow 63e2e36735a6 46 hours ago 704MB
airflow latest 63e2e36735a6 46 hours ago 704MB
docker/getting-started latest 083d7564d904 6 weeks ago 28MB
Why is this creating new containers?
If you run docker run ... you spin out a new cointainer from the image.
The status of your container is Exited as you can check from the docker ps -a output.
If you want to start again the same container, you can try docker start abc6f4d50931.

docker, container is not running

docker ps shows instances, but when I try to log in to the instance, it says it's not running?
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
eaa62ff2df11 monitor_kibana "/usr/local/bin/dumb…" 4 months ago Up 9 days kibana
613dc901f2e1 monitor_elasticsearch-search "/usr/local/bin/dock…" 4 months ago Up 9 days elasticsearch-search
$ docker exec -it eaa62 bash
Error response from daemon: Container eaa62ff2df11547744c5f7cf82cad16bf576820d2a209c4f19f173cca68f5511 is not running
$
Could it be that the container only runs for a very short time? If you use the -a flag in your statement to get only active containers, like so:
docker ps -a
Does it still show up? It could be that it runs and just uses something like ECHO. In that case, because the program run succesfully the container is immediately terminated.
Is this an official image? If so, try to run the container without the -d (for deamon) flag. This should output the run information to terminal and give you some information on what is going on.
sudo docker exec -it eaa62 bash

Can't get my Docker Container to start and give me a shell

I am trying to get a Docker Container running. I am following this guide: http://opendata.cern.ch/docs/cms-guide-docker.
The container refuses to start and give me access to the shall I expect.
Running the following command (as mentioned in the guide) does nothing, the process exits with a non-0 exit code. The first time I ran it, it downloaded the container image but did not land me into the sell as the guide says it would.
$ docker run --name opendata-2010 -it cmsopendata/cmssw_4_2_8 /bin/bash
I can see the container, it exits soon as it starts.
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
be670158d200 cmsopendata/cmssw_5_3_32 "/opt/cms/entrypoint…" 34 minutes ago Exited (139) 3 seconds ago opendata
These are other things I have tried to no avail.
$ docker exec -it be670158d200 /bin/bash
Error response from daemon: Container be670158d200ae85871fbda810fa6074dcb7bc8fc606f000710f630add1b80b6 is not running
$ docker start --attach be670158d200
failed to resize tty, using default size
My question is similar to this: Docker - Container is not running, but I know that unlike in that question, here I should be getting the shell.
I am running this in Windows Subsystem for Linux 2 - Ubuntu 20.04, docker version 19.03.8 - build afacb8b7f0. Any help is greatly appreciated, thanks.
I had the same error with below logs
dockerd[15309]: time="2022-01-11T11:13:35.133154132+05:30" level=error msg="Handler for POST /v1.41/exec/94553dc2f9aaa3c1245df7384138786a8a576af99105a285258fce8b980b4660/resize returned error: timeout waiting for exec session ready"
This is a bug in docker 20.10 version and can be solved by downgrading containerd rpm
Removed:
containerd.io.x86_64 0:1.4.4-3.1.el7
Installed:
containerd.io.x86_64 0:1.4.3-3.1.el7

Al docker images exit 126 status

I have just installed Ubuntu 20.0 and installed docker using snap. I'm trying to run some different docker images for hbase and rabbitmq but each time I start an image, it immediately exists with 126 status.
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d58720fce3a dajobe/hbase "/opt/hbase-server" 5 seconds ago Exited (126) 4 seconds ago hbase-docker
b7a84731a05b harisekhon/hbase "/entrypoint.sh" About a minute ago Exited (126) 59 seconds ago optimistic_goldwasser
294b95ef081a harisekhon/hbase "/entrypoint.sh" About a minute ago Exited (126) About a minute ago goofy_tu
I have tried everything and tried to use docker inspect on separate images, but nothing gives away, why the containers exit out immediately. Any suggestions?
EDIT
When i run the command i run the following
$ sudo bash start-hbase.sh
It gives the output exactly like it should
Starting HBase container
Container has ID 3c3e36e1e0fbc59aa0783a4c7f3cb8690781b2d04e8f842749d629a9c25e0604
Updating /etc/hosts to make hbase-docker point to (hbase-docker)
Now connect to hbase at localhost on the standard ports
ZK 2181, Thrift 9090, Master 16000, Region 16020
Or connect to host hbase-docker (in the container) on the same ports
For docker status:
$ id=3c3e36e1e0fbc59aa0783a4c7f3cb8690781b2d04e8f842749d629a9c25e0604
$ docker inspect $id
I think the issue might be due to some permissions, because i tried to chck the logs as suggested in the comments, and get this error:
/bin/bash: /opt/hbase-server: Permission denied
Check if the filesystem is mounted with noexec option using mount command or in /etc/fstab. If yes, remove it and remount the filesystem (or reboot).
Quick solution is restart service docker and network-manager

Docker doesn't recognize the -p command all of a sudden

So I just updated Docker on my Mac and getting adjusted to Docker seems to be quite challenging and confusing.
A few weeks ago, I was able to mind port 8834 on the docker container to port 8834 on my local host by running the following commands (this is my command line history):
8450 docker attach -p 8834:8834 compassionate_chandrasekhar
8452 docker start -p 8834:8834 compassionate_chandrasekhar
Today, if I try to do the same thing, the following happens:
[user:test.local:]$ docker container ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
225146ec71d6 myuser/kali:kali "/usr/bin/zsh" 9 minutes ago Exited (0) 2 minutes ago agitated_fermat
e4389cac288a myuser/kali:kali "/usr/bin/zsh" 2 weeks ago Exited (255) 2 weeks ago suspicious_hypatia
265f2c9215c5 myuser/kali:kali "/usr/bin/zsh" 2 weeks ago Exited (0) 2 weeks ago hungry_poincare
34b36b4d8a7e myuser/kali:kali "/usr/bin/zsh" 2 weeks ago Created amazing_stonebraker
followed by:
[user:test.local:]$ docker start -p 8834:8834 agitated_fermat
unknown shorthand flag: 'p' in -p
See 'docker start --help'.
What am I doing wrong? Extremely confusing
Publishing ports can be done only with newly created containers not existing containers. So you need to stop the container and create a new one with the port you need
Today I was grabbing a Jenkins/Docker-tutorial, and got a similar error.
They do say to start the container the following way, but I got the same error as you:
docker run --name jenkinsci -p 8080:8080 jenkins/jenkins:lts
=> "unknown shorthand flag: 'p' in -p"
When I put the "name"-tag at the end I no longer get the error, and it downloads the container.
docker run -p 9090:8080 jenkins/jenkins:lts --name jenkinsci
It now tells me it does not recognize the option "--name"-tag after downloading.
Without "--name" the container runs.
(Tutorial link: https://medium.com/#gustavo.guss/quick-tutorial-of-jenkins-b99d5f5889f2)

Resources