Docker installation on Mac m1 - docker

I am trying to install Docker desktop on Mac m1 but after installation dockers asks to execute following command.
docker run -d -p 80:80 docker/getting-started
But, it gives following error
Unable to find image 'docker/getting-started:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": read tcp 192.168.65.4:58764->192.168.65.5:3128: read: connection reset by peer.
See 'docker run --help'.
Why is it not pulling docker data?

(Sorry for the miss... going to try this again)
Try docker exec command before your command.
Like this docker exec docker run -d -p 80:80 docker/getting-started
"Tried using the docker exec command and it appears to have worked OK with two different ubuntu instances. Did not try Docker Desktop.
It kind of looks like there is a problem with Docker Desktop manipulating Terminal.app.
I’m using the macOS default zshell."
https://forums.docker.com/t/problems-getting-started/116487/9

Related

unable to run docker container docker4dotnet/nanoserver

Learning docker following a course in udemy. i have all the prerequisites like docker desktop and switched to windows container. While trying to run a container using
docker container run docker4dotnet/nanoserver hostname
getting error like below
Unable to find image 'docker4dotnet/nanoserver:latest' locally
latest: Pulling from docker4dotnet/nanoserver
b5c97e1d373f: Extracting [==================================================>] 103MB/103MB
docker: failed to register layer: re-exec error: exit status 1: output: hcsshim::ProcessBaseLayer \?\C:\ProgramData\Docker\windowsfilter\90f22cdfe817e491c24b8e26f35b4ec43c6477ce0c86cdbfb95a59e2606762a5: The semaphore timeout period has expired.
unable to figure it out. can some one help on this
NOTE : tried to switch the container to linux but it says
Unable to find image 'docker4dotnet/nanoserver:latest' locally
latest: Pulling from docker4dotnet/nanoserver
b5c97e1d373f: Downloading
docker: image operating system "windows" cannot be used on this platform.
NOTE 2 : Even tried
docker run -d -p 8090:80 docker/getting-started it says below even though windows container is selected
PS C:\WINDOWS\system32> docker run -d -p 8090:80 docker/getting-started
docker: Error response from daemon: operating system on which parent image was created is not Windows.
use this lines in cmd:
docker pull mcr.microsoft.com/windows/nanoserver:20H2
docker container run mcr.microsoft.com/windows/nanoserver:20H2 hostname

Running docker container on windows with a volume gives me an error

I'm trying to run a simple docker image with a volume
docker run -dit -v J:\dvolumes:/data ubuntu
However I get the following error
docker: Error response from daemon: invalid mode: data.
I'm guessing it's thinking the ':' after the J is what separates the volume but I don't really know how to make it think otherwise (if that's the case).
Any help would be greatly appreciated
Issue was that I was trying to run the container in WSL2 so I should be using linux paths
WSL2
docker run -dit -v /j/dvolumes:/data ubuntu
Windows
docker run -dit -v j:/dvolumes:/data ubuntu

docker run results in "unable to find image" if linked container not found

I'm getting possibly incorrect behavior and a bad error message if I run an image if a linked container is not found:
# this works:
> docker run --rm -d --name natsserver nats
> docker run --rm -it --name hello-world --link natsserver hello-world
# now stop natsserver again...
> docker stop natsserver
When I run hello-world again with the same command, I don't understand the first part of the error handling - why does docker try to pull?
> docker run --rm -it --name hello-world --link natsserver hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
Digest: sha256:b8ba256769a0ac28dd126d584e0a2011cd2877f3f76e093a7ae560f2a5301c00
Status: Image is up to date for hello-world:latest
docker: Error response from daemon: could not get container for natsserver: No such container: natsserver.
See 'docker run --help'.
And things get even worse if I try to run an image I have built locally:
> docker build -t nats-logger .
[...]
Successfully tagged nats-logger:latest
> docker run --rm -it --name nats-logger --link=natsserver nats-logger
Unable to find image 'nats-logger:latest' locally
docker: Error response from daemon: pull access denied for nats-logger, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
So my questions are:
a) Is docker allowed to try to pull in this case, or is this a bad behavior?
b) Is this really a bad error message, or did I miss something?
P.S.: I'm running Docker version 19.03.2, build 6a30dfc on Windows 10.
Is docker allowed to try to pull in this case
Docker will pull image if it is not available on the machine.
Unable to find image 'hello-world:latest' locally
This warning message is not due to linking, it is because hello-world:latest is not exist in your system local images. so whe run docker run it will look on local then will pull from remote if not exist.
Now First thing, Better to use docker-compose instead of Legacy container links.
You can not link the container if it's not running. verify the container natsserver using docker ps and then if it is running then you can link.
docker run --rm -it --name hello-world --link natsserver:my_natserver_host hello-world
Once up you can then check the linking.
docker inspect hello-world | grep -A 1 Links
Legacy container links
Warning: The --link flag is a legacy feature of Docker. It may
eventually be removed. Unless you absolutely need to continue using
it, we recommend that you use user-defined networks to facilitate
communication between two containers instead of using --link. One
feature that user-defined networks do not support that you can do with
--link is sharing environment variables between containers. However, you can use other mechanisms such as volumes to share environment
variables between containers in a more controlled way.
simply try "docker login".
check if your image name is exist in docker hub
and check correct docker build command -> docker build -t image-name .
review the correctness of Docker file script

docker command not running

I am new to docker and trying to run the following codes and getting the error below.
Nihits-MacBook-Pro:~ nihit$ docker container run --publish 80:80 nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
bc95e04b23c0: Pull complete
110767c6efff: Pull complete
f081e0c4df75: Pull complete
Digest: sha256:004ac1d5e791e705f12a17c80d7bb1e8f7f01aa7dca7deee6e65a03465392072
Status: Downloaded newer image for nginx:latest
docker: Error response from daemon: driver failed programming external connectivity on endpoint gracious_pare (0a28a065694108085e2b7533870d9d84889899baf5d4130c58c49c4736bb6b12): Error starting userland proxy: Bind for 0.0.0.0:80: unexpected error (Failure EADDRINUSE).
ERRO[0016] error waiting for container: context canceled
I tried different codes with port but all of them get stuck and don't do anything.
Nihits-MacBook-Pro:~ nihit$ docker container run --publish 3000:80 nginx
Nihits-MacBook-Pro:~ nihit$ docker container run --publish 8080:80 nginx
None of them work and just are stuck on the terminal.
This should work
docker container run --publish 3000:80 nginx:latest
Since I read the above conversation, it looks like you recieved a long string of number meaning that docker is running, just hit the url localhost:3000 you will see nginx running.
Normally port:80 is used by php if you have apache installed on your computer.
If it gets stuck it also means that the docker is running but not in the background.
Normally the --detach or -d means that the docker will provide you the long string of numbers which tells docker to run the app in the background so you won't see anything happening in the terminal.
Would you mind to try the below command to start the nginx again?
$ docker run -d -p 80:80 nginx:latest
BTW, all commands which start with "docker container" seems the new commands from docker.
But, according to the https://docs.docker.com/edge/engine/reference/commandline/docker/,
the function of "docker container run" should be same as "docker run".
Not sure why difference between those two commands.
In my cases, I'm seldom to use the commands which start with "docker container" to execute my container.
If the container successfully started, the shell will return the message such as follows:
sh-3.2# docker run -d -p 8080:80 nginx:latest
b0a5aa7965119c5b2705392b5b9e9640a4ab8edefda6722ee86da507229cdf05
sh-3.2#
sh-3.2# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED
b0a5aa796511 nginx:latest "nginx -g 'dae... About a minute ago...

Get TeamCity running on Docker

I'm brand new to both TeamCity and Docker. I'm struggling to get a Docker container with TeamCity running and usable on my local machine. I've tried several things, to no avail:
I installed Docker for Mac per instructions here. I then tried to run the following command, documented here, for setting up teamcity in docker:
docker run -it --name teamcity-server-instance \
-v c:\docker\data:/data/teamcity_server/datadir \
-v c:\docker\logs:/opt/teamcity/logs \
-p 8111:8111 \
jetbrains/teamcity-server
That returned the following error: docker: Error response from daemon: Invalid bind mount spec "c:dockerdata:/data/teamcity_server/datadir": invalid mode: /data/teamcity_server/datadir.
Taking a different tack, I tried to follow the instructions here - I tried running the following command:
docker run -it --name teamcity -p 8111:8111 sjoerdmulder/teamcity
The terminal indicated that it was starting up a web server, but I can't browse to it at localhost, nor at localhost:8111 (error ERR_SOCKET_NOT_CONNECTED without the port, and ERR_CONNECTION_REFUSED with the port).
Since the website with the docker run command says to install Docker via Docker Toolbox, I then installed that at the location they pointed to (here). I then tried the
docker-machine ip default
command they suggested, but it didn't work, error "Host does not exist: "default"". That makes sense, since the website said the "default" vm would be created by running Docker Quickstart and I didn't do that, but they don't provide any link to Docker Quickstart, so I don't know what they are talking about.
To try to get the IP address the container was running on, I tried this command
docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
That listed the names of the running containers, each followed by a hyphen, then nothing. I also tried
docker ps -a
That listed running contaners also, but didn't give the IP. Also, the port is blank, and the status says "exited (130) 4 minutes ago", so it doesn't seem like the container stayed alive after starting.
I also tried again with port 80, hoping that would make the site show at localhost:
docker run -it --name teamcity2 -p 80:80 sjoerdmulder/teamcity
So at this point, I'm completely puzzled and blocked - I can't start the server at all following the instructions on hub.docker.com, and I can't figure out how to browse to the site that does start up with the other instructions.
I'll be very grateful for any assistance!
JetBrains now provides official docker images for TeamCity. I would recommend starting with those.
The example command in their TeamCity server image looks like this
docker run -it --name teamcity-server-instance \
-v <path to data directory>:/data/teamcity_server/datadir \
-v <path to logs directory>:/opt/teamcity/logs \
-p <port on host>:8111 \
jetbrains/teamcity-server
That looks a lot like your first attempt. However, c:\docker\data is a Windows file path. You said you're running this on a mac, so that's definitely not going to work.
Once TeamCity starts, it should be available on port 8111. That's what -p 8111:8111 part of the command does. It maps port 8111 on your machine to port 8111 in the VM Docker for Mac creates to run your containers. ERR_CONNECTION_REFUSED could be caused by several things. Two most likely possibilities are
TeamCity could take a little while to start up and maybe you didn't give it enough time. Solution is to wait.
-it would start the TeamCity container in interactive mode. If you exit out of the terminal window where you ran the command, the container will also probably terminate and will be inaccessible. Solution is to not close the window or run the container in detached mode.
There is a good overview of the differences between Docker for Mac and Docker Toolbox here: Docker for Mac vs. Docker Toolbox. You don't need both, and for most cases you'll want to use Docker for Mac for testing stuff out locally.

Resources