what the error 'decode config err' means in docker's log - docker

I installed docker on Centos and pulled a wechat image with the following command:
docker pull cynen/wechat:latest
Then I created a config.json file in /home/wechat with the following content:
{
"api_key": "sk-****",
"auto_pass": false,
"model": "text-davinci-003",
"session_timeout": 60
}
Next I started the container with the following command:
docker run-dti --name wechat -v /home/wechat:/app/ cynen/wechat
After the container is successfully started, I viewed the log with the following command:
docker logs -f wechat
Then I got the following displayed:
decode config err: invalid character 'A' looking for beginning of object key string
What causes this? I checked for a long time and did not find the answer, did any one konws the reason? thank you 🙏!
The correct log content should be the text showing a wechat login QR code.

Related

install docker container - docker run - invalid reference format

From the docker quickstart terminal on Windows 7 64-bit, I'm following the instructions to install this docker container. I run the command,
docker run http://wiki.openstreetmap.org/wiki/nominatim
and I get this error:
c:\program files\docker toolbox\docker.exe: invald reference format.
I can't find any information about this error related to this container.
You need to pull the image first , then run the container. according to your docker command, you are trying to access a website, it is not a docker container image. so that's why it is giving you the invalid reference format.
The image name that you have specified to pull and run is wrong. The image name should be mediagis/nominatim.
Your docker run command should be
docker run mediagis/nominatim
It is not necessary to pull the image first and run it. By default docker run first tries to find such image in your machine if not then it tries to download from docker repository.
If you specify URL format it directly downloads from private repo if such image is not found in your machine.
Brief Explanation:
Docker takes whatever that is in form of url as an image and the reason for this is sometimes you may want to run image from your private repository. So here http://wiki.openstreetmap.org/wiki/nominatim is considered as an image called wiki/nominatim from a private repo called wiki.openstreetmap.org by docker and the format of private repo and image is wrong . It should be <domain.com>/image:tag where tag is optional. You are not supposed to provide protocol (http://). See this for reference Hence the error is thrown as invalid reference format.
If you would have given as docker run wiki.openstreetmap.org/wiki/nominatim it would have tried to download image called wiki/nominatim from wiki.openstreetmap.org private repo with latest tag. Since no such repo and image exists it reports Error response from daemon: error parsing HTTP 404 response body as the url throws 404: Not Found when docker daemon tries connecting to it.
References:
Pull an image from Docker Hub
Pull from a different registry
docker run
Docker run reference
Note: Unless you specify tag name which is optional docker always downloads latest tag from repo.
docker run http://wiki.openstreetmap.org/wiki/nominatim
does non make any sense syntactically ...
In any case the correct command to get the latest image is:
sudo docker pull mediagis/nominatim:3.1
Notice that each version has its own installation instructions (versions prior to 3.1 were structurally different), so please do refer to the appropriate section:
https://hub.docker.com/r/mediagis/nominatim/tags/
However I do agree with you that
docker run --restart=always -p 6432:5432 -p 7070:8080 -d -v /home/me/nominatimdata/postgresdata:/var/lib/postgresql/9.5/main nominatim sh /app/start.sh
Should be
docker run --restart=always -p 6432:5432 -p 7070:8080 -d -v /home/me/nominatimdata/postgresdata:/var/lib/postgresql/9.5/main mediagis/nominatim sh /app/start.sh
instead. The installation instructions need updating there.

How to push OpenFaaS image to Minishift/Openshift Docker registry?

I'm trying to deploy a locally written OpenFaaS function to Minishift. My YAML file is:
provider:
name: faas
gateway: http://gateway-openfaas.10.10.80.33.nip.io
functions:
test:
lang: python
handler: ./test
image: 172.30.1.1:5000/test
172.30.1.1:5000 is the result of calling
minishift openshift registry
When I access the OpenFaaS UI through the Openshift Console, I can deploy functions properly from there. I can also see the function I tried to deploy locally there, but the Docker image is not in the Minishift Docker registry. To push my image there, I'm trying to use the command:
faas-cli push -f ./test.yml
Unfortunately, I receive the following error:
PS D:\projects> faas-cli push -f ./test.yml
[0] > Pushing test.
The push refers to a repository [172.30.1.1:5000/test]
8124325a272a: Preparing
2fbb584cb870: Preparing
e6dd715c8997: Preparing
ac20ff3419a9: Preparing
18adf8f88cf9: Preparing
ab495c1b9bd4: Waiting
09c56bd3ad6c: Waiting
a291b1700920: Waiting
8a65d1376e5b: Waiting
155a0aa5c33a: Waiting
8984417f4638: Waiting
a7d53ea16e81: Waiting
e53f74215d12: Waiting
unauthorized: repository name "test" invalid: it must be of the format
<project>/<name>
2018/03/22 11:30:53 ERROR - Could not execute command: [docker push
172.30.1.1:5000/test]
What am I doing incorrectly? Any assistance is appreciated.
Looks like you need a project name before your image name, like openshift in the following example
$ docker push 172.30.124.220:5000/openshift/busybox
...
cf2616975b4a: Image successfully pushed
Digest: sha256:3662dd821983bc4326bee12caec61367e7fb6f6a3ee547cbaff98f77403cab55
Try changing the image section in your test.yml to be 172.30.1.1:5000/openfaas/test or similar.
You may also need to get an access token and use it with docker login, as described in the above link, if you have not already done so:
$ oc whoami -t
$ docker login -u <username> -e <any_email_address> -p <token_value> <registry_service_host:port>
#codemonkey is right. One need to include project name as part of any application image.
Also, I would suggest you to try $(minishift openshift registry) since if you give you registry IP:Port.
See more detail See more https://docs.openshift.org/latest/minishift/openshift/openshift-docker-registry.html.

Running a docker container via Jupiter Notebook

I've searched for a number of hours to find the answer to this because I want to respect the idea of non-redundant posts. I'm sure the fact that I'm relatively new to programming doesn't help but here's my issue (hopefully I present it in the correct way):
I am taking a Computational Finance class that requires the package 'qstk'. There is a docker image setup with everything needed for the course, under the docker file 'ruippeixotog/qstk'. I followed the following instructions to access this docker file via the Jupiter notebook and was successful but ever since that first use of the file, I can no longer access the notebook.
I have the current version of Docker downloaded and follow the same instructions to access the notebook via a web browser (I've tried Safari, Chrome, and Firefox) but always get the error code "
install docker whatever OS you have (it officially supports Windows,
Mac, Linux) by following the instructions on the Docker website start
it, still following the instructions on the website
List item
execute on command line: docker run -dt -p 8888:8888 --name qstk
ruippeixotog/qstk
open your browser at http://localhost:8888 and you have a python
interpreter with QSTK fully configured
The source repository is at: https://github.com/ruippeixotog/docker-qstk
My process:
I run docker with: docker run -dt -p 8888:8888 --name qstk ruippeixotog/qstk
I go to http://localhost:8888
And I get the response from the browser: "Failed to open page...server unexpectedly dropped the connection"
If I run:
I run docker with: docker run -dt -p 8888:8888 --name qstk ruippeixotog/qstk
jupyter notebook
It brings me to my tree of file folders (localhost:8888/tree), where the two files
"QSTK-0.2.5.tar.gz" and
"QSTK-0.2.5.tar.gz.cpgz"
Are located, along with a bunch of my other folders. When I try to edit the first of those two files, it opens a new tab and tells me "SSL is required." within the jupyter editor page for that file, showing nothing else
When I try to edit the second, it shows only "Error! /Users/.../QSTK-0.2.8
Can anyone help with this?

Docker: Unable to redirect output to text file?

So I have a shell script, a snippet displayed below
sudo docker start -ai <ContainerID> > /textfile.text
sudo docker cp <ContainerID>:/textfile.text /directorytomoveto/
where I wish to store the output of a process in a text file in the top directory of the container. The container executes the process and the output isn't displayed, which is a good sign. However, I get the following error:
Error response from daemon: Could not find the file /textfile.txt in container <ContainerID>
Anyone see a mistake or a way of fixing this? Thanks.
If you want the container logs, you can simply get them by running docker container logs <containerId>. You can redirect the output to a log file directly on the host.
Moreover, as other have stated the > /textfile.text is executing on the host, and even if it did execute in the container, it would have overriden the container command that starts it, which will make the container process not start.

How to see the logs of a docker container

I have a simple code for which I have created a docker container and the status shows it running fine. Inside the code I have used some print() commands to print the data. I wanted to see that print command output.
For this I have seen docker logs . But it seems not to be working as it shows no logs. How to check logs.?
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a3b3fd261b94 myfirstdocker "python3 ./my_script…" 22 minutes ago Up 22 minutes elegant_darwin
$ sudo docker logs a3b3fd261b94
<shows nothing>
The first point you need to print your logs to stdout.
To check docker logs just use the following command:
docker logs --help
Usage: docker logs [OPTIONS] CONTAINER
Fetch the logs of a container
Options:
--details Show extra details provided to logs
-f, --follow Follow log output
--help Print usage
--since string Show logs since timestamp
--tail string Number of lines to show from the end of the logs (default "all")
-t, --timestamps Show timestamps
Some example:
docker logs --since=1h <container_id>
4
Let's try using that docker create start and then logs command again and see what happens.
sudo docker create busybox echo hi there
output of the command
now I will take the ID and run a docker start and paste the ID that starts up the container it executes echo high there inside of it and then immediately exits.
Now I want to go back to that stopped container and get all the logs that have been emitted inside of it.
To do so I can run at docker logs and then paste the ID in and I will see that when the container had been running it had printed out the string Hi there.
One thing to be really clear about is that by running docker logs I am not re-running or restarting the container to in any way shape or form, I am just getting a record of all the logs that have been emitted from that container.
docker logs container_id
If there's not so much supposed output (e.g. script just tries to print few bytes), I'd suspect python is buffering it.
Try adding more data to the output to be sure that buffer is flushed, and also using PYTHONUNBUFFERED=1 (although, python3 still may do some buffering despite of this setting).

Resources