Docker - unknown command "run" - docker

I am trying to run a docker container on an Ubuntu WSL2 instance on Windows 10. Docker version installed in 20.10.17. I have been able to run docker commands and build the image successfully.
The output of docker images:
When I try to run the container using the command docker run -p 5000:5000 test it gives the following error:
I have never had this issue with docker before and not sure why it thinks it's an npm command. Does anyone know why this is happening?

Related

Can't acces apache on docker from my network

I have this Dockerfile :
FROM ubuntu:20.04
EXPOSE 80
After installing apache2 package in the container I can't acces the default page of apache from the network. Also docker is in a virtual machine with debian 10. If I try the official apache image (https://hub.docker.com/_/httpd) everything works fine but I want to know why installing it manually doesn't work.
To build the container from the image I use this command :
sudo docker run --name ubuntu -p 80:80 -it ubuntu /bin/bash
I have run the exactly same test on my virtual centos machine and found working.
I've build the image using your dockerfile and run apache installation using below command.
docker build -t ubuntu
docker run --name ubuntu -p 80:80 -it ubuntu /bin/bash
and In terminal opened by the above mentioned command, i ran the below command.
apt-get update
apt-get install apache2
service apache2 start
After that opened another ssh terminal keeping the current running as i have not run the Ubuntu container in detached mode and checked by using.
docker ps -a
and found container is running with exposing 0.0.0.0:80 and checked
curl localhost
Please make sure you have not stoped docker container before running curl command or hit in the browser as its not run in detached mode or background.

Does docker pull image in Powershell install on Windows system as well

I executed the, "docker pull nginx" in Windows Powershell.
On pulling it downloads an image which is in a few MB's
I have Windows 10 pro.
Then i ran nginx as below,
"docker run --name mynginx1 -P -d nginx"
Does the pull command also install nginx on my Windows machine as well ?
No - the docker pull command doesn't install anything, it just downloads the docker image locally. After the pull there's no container running on the host (which is actually a VM in Windows - slightly different if you're using docker desktop or docker-machine, but I won't get into the weeds here). The docker run command is what actually runs a container in the docker host.

Can't run Raspbian container on docker

So I've installed the hypriot OS for docker and I have tested it with ocker run -d -p 80:80 hypriot/rpi-busybox-httpd. All is well and the test works.
However, when I run docker run -i -t resin/rpi-raspbian to get raspbian nothing happens and docker ps shows no containers running. There are no error messages.
What is happening to my raspbian container?
Thanks
Running on Mac OSX and having downloaded the resin/rpi-raspbian image, I issue the command:
docker run -i -t resin/rpi-raspbian /bin/bash
which starts the container and puts me at the command prompt in raspbian.

run docker commands from command prompt versus jenkins script

I have a test Ubuntu server with docker-machine installed. I have a number of docker containers running on the servers. Including a Jenkins container. I run jenkins with the following command
docker run -d --name jenkins -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/usr/bin/docker --restart=always -p 8080:8080 -v ~/jenkinsHome:/var/jenkins_home docker-jenkins
I am working on managing my images through Jenkins. I can start all but one of my containers via Jenkins shell script. The one container that fails appears to start in the script (I do a docker PS after the docker run in script). However, the container stops after the script completes. I am using the same docker run command that works on the command prompt, but it fails in Jenkins script:
sudo docker run -d --net=host -v ~/plex-config:/config -v ~/Media:/media -p 32400:32400 wernight/plex-media-server
I have double checked folder permissions and they are correct. Can anyone direct me to possible reasons the run command is failing in Jenkins, but not at the command prompt?
using docker ps -a I was able to get an ID for the stopped container. Then by using docker logs I was able to see the error was a folder permission issue. Then digging deeper, it was a user permission error mis-match between the user Jenkins runs as inside it's container not being able to pass the folder correctly. I have decided to circumvent the problem by using docker stop and start commands and not using the docker run command.

OS name for docker images

I am trying to build a new docker image using docker provided base Ubuntu image. I'll be using docker file to run few scripts and install applications on the base image. However my script requirement is that the hostname should remain same. I couldn't find any information on OS names for docker images. Does anybody has an idea that once we add layers to a docker image does the OS name remains same.
You can set the hostname with the -h argument to Docker run, otherwise it gets the short form of the container ID as the hostname:
$ docker run --rm -it debian bash
root#0d36e1b1ac93:/# exit
exit
$ docker run --rm -h myhost -it debian bash
root#myhost:/# exit
exit
As far as I know, you can't tell docker build to use a given hostname, but see Dockerfile HOSTNAME Instruction for docker build like docker run -h.

Resources