I have a running container in Docker. When I try to access it via PowerShell using:
docker run curl -d '{ "action" : "version" }' localhost:17076
it says
Unable to find image 'curl:latest' locally
docker: Error response from daemon: pull access denied for curl, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
Though I am able to use the above function starting with curl -d '{... when being inside the Docker-Terminal.
The command docker ps within PowerShell returns container ID Image Command Created Status Ports and Names with the adequate information.
Is there anyone with an idea how to access the running container from PowerShell?
I think you're looking for the command docker exec rather than docker run. As in, something like the following:
docker exec -it <container_name> sh -c "curl -d '{ \`"action\`" : \`"version\`" }' localhost:17076"
Related
I have deployed the tensorflow-serving docker image with the path to tf model.
The REST api (/predict) is working as expected. But, the problem is , to use the model in production environment exporting logs to kibana is expected.
here is the current command to run the docker container : sudo docker run -h 0.0.0.0 -p 80:8501 --mount type=bind,source=/pathto model/somemodel/,target=/models/somemodel -e MODEL_NAME=somemodel -t tensorflow/serving:2.8.2
i tried printing the logs with docker logs <dockerid>
please let me know how to obtain error and request logs from docker container?
Things i have tried :
tried adding -e TF_CPP_MAX_VLOG_LEVEL=4 to docker run command
tried adding -e TF_CPP_VMODULE=http_server=3 to docker run command
the command line argument mentioned in this discussion doesn't seem to work : https://stackoverflow.com/a/64046022/7382421
I have Ubuntu 22.04 and run next command:
docker run -d mypostgres -e POSTGRES_PASSWORD=1111 postgres -c shared_buffers=256MB -c max_connections=200
and I got following answer:
Unable to find image 'mypostgres:latest' locally
docker: Error response from daemon: pull access denied for mypostgres, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
So what is the correct name for 'mypostgres'?
Can I write here the occasional name that I want?
You should use postgres instead if you want to download the image from dockerhub. If you want specific version you can use tags provided on the dockerhub page ie. postgres:14.5
What you are missing here is --name switch before mypostgres You can use --name switch to name your container
Full command:
docker run -d --name mypostgres -e POSTGRES_PASSWORD=1111 postgres -c shared_buffers=256MB -c max_connections=200
--name before mypostgres , because docker understood that you want an image called mypostgres not a postgres images. and didn't find an official image with that name.
I am trying to execute a command on a docker container that is running in a remote server. I am running most commands through ssh and they all work correctly. However, this command modifies the file /etc/environment and I get a "permission denied" error.
The command in question is docker exec container_id echo 'WDS_SOCKET_PORT=XXXXX' >> /etc/environment
If I run the command from the docker host, it works
If I run a simple command remotely using ssh user#ip docker exec container_id ls, it works
If I run this command remotely using ssh user#ip docker exec container_id echo 'WDS_SOCKET_PORT=XXXXX' >> /etc/environment I get sh: 1: cannot create /etc/environment: Permission denied
I tried adding the option -u 0 to the docker exec command with no luck.
I don't mind making changes to the Dockerfile since I can kill, remove or recreate this container with no problem.
The error isn't coming from docker or ssh, it's coming from your shell that parses the command you want to run. You are trying to modify the file on your host. To do io redirection inside the container, you need to run a shell there and parse the command with that shell.
ssh user#ip "docker exec container_id /bin/sh -c 'echo \"WDS_SOCKET_PORT=XXXXX\" >> /etc/environment'"
EDIT: Note that the whole docker command should be surrounded by quotes. I believe this is because ssh might otherwise parse different parts of the command as parameters of the docker command. This way, each sub-command is clearly delimited.
Suddenly my docker run stopped working last night, which was working before. docker build is working fine, but I get the below error when trying to run the container.
Command
docker run -it --rm -p 9001:4200 -v ${pwd}/src:/app/src angularclient
Error message
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error
response from daemon: Mount denied: The source path
"E:/Karthik/angular/src" doesn't exist and is not known to Docker. See
'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.
I tried running the following command in the power shell:
refreshenv
set MSYS_NO_PATHCONV=1
set COMPOSE_CONVERT_WINDOWS_PATHS=1
try this:
docker run -it --rm -p 9001:4200 -v E:/Karthik/angular/src:/app/src angularclient
It seems that you can't use ${pwd} and ./ on win cmd and Git Bash. You can only use absolute paths.
Add this on your ~/.bash_profile:
export MSYS_NO_PATHCONV=1
Add / to prefix of path as below.
docker run -it --rm -p 9001:4200 -v /${pwd}/src:/app/src angularclient
Ensure the drive is shared in Docker settings "Shared Drives".
Create the full path if it doesn't already exist.
Add trailing / to the path.
I am getting an error message 'Error from daemon: container is not running". Why? I started the container in detached mode, so it should be running? I tried the -it flags for interactivity but that did not work. I also tried sleeping docker but that did not work.
sh "docker run -d --name mongocontainer19"
sh "docker exec mongocontainer19 mongo mongodump"
The --name gives container names, which is mongocontainer19 in your case. So, you didn't put the image name there.
The syntax is
$ docker run [OPTIONS] IMAGE
So the command should be like$ docker run -d --name mongocontainer19 MyRedisIMAGE
--name <Your_container_alias> will be considered as an option of the command. -d or -p xx:xx are options as well.