Docker Remote API does not list containers - json

I have locally installed docker server which runs one container.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3d7ef4f6bb0a debian "/bin/bash" 7 hours ago Up 7 hours 0.0.0.0:80->2376/tcp nostalgic_fermat
when I tried to use the docker remote API in order to get the information about this container I did not see the json output about the containers running on host. The result from rest call is:
wget -v 192.168.99.100:2376/containers/json/
--2016-01-16 23:57:20-- http://192.168.99.100:2376/containers/json/
Connecting to 192.168.99.100:2376... connected.
HTTP request sent, awaiting response... 200 No headers, assuming HTTP/0.9
Length: unspecified
Saving to: 'index.html.3'
index.html.3 [ <=> ] 7 --.-KB/s in 0s
2016-01-16 23:57:20 (297 KB/s) - 'index.html.3' saved [7]
What exactly I am missing?
The version of API is:
Client:
Version: 1.9.0
API version: 1.21
Go version: go1.4.3
Git commit: 76d6bc9
Built: Tue Nov 3 19:20:09 UTC 2015
OS/Arch: darwin/amd64
EDIT (RESOLVE)
It appears that docker server requires SSL authentication. I was able to authorized to docker localhost by providing the local docker server certificates.
The following command stores json file with information of all containers running on local docker server.
wget --no-check-certificate --ca-certificate ca.pem --certificate=cert.pem --certificate-type=PEM --private-key=key.pem --private-key-type=PEM https://192.168.99.100:2376/containers/json

Related

Configure wiki.js(open source) on AWS EC2 instance

I've deployed wiki.js on AWS EC2 instance using docker. With installation Command as follows :
docker run -d -p 8080:3000 --name wiki --restart unless-stopped -e "DB_TYPE=mysql" -e "DB_HOST=172.0.0.1" -e "DB_PORT=3306" -e "DB_USER=wikijs" -e "DB_PASS=wikijsrocks" -e "DB_NAME=wiki" requarks/wiki:2
I've referred wiki.js installation .
DB container and wiki containers are running in the same instance, When I check the above-created container logs, it shows the below output.
Loading configuration from /wiki/config.yml... OK
2021-07-21T16:13:45.924Z [MASTER] info: =======================================
2021-07-21T16:13:45.926Z [MASTER] info: = Wiki.js 2.5.201 =====================
2021-07-21T16:13:45.926Z [MASTER] info: =======================================
2021-07-21T16:13:45.927Z [MASTER] info: Initializing...
2021-07-21T16:13:47.149Z [MASTER] info: Using database driver mysql2 for mysql [ OK ]
2021-07-21T16:13:47.153Z [MASTER] info: Connecting to database...
2021-07-21T16:13:47.189Z [MASTER] info: Database Connection Successful [ OK ]
2021-07-21T16:13:47.237Z [MASTER] warn: DB Configuration is empty or incomplete. Switching to Setup mode...
2021-07-21T16:13:47.238Z [MASTER] info: Starting setup wizard...
2021-07-21T16:13:47.477Z [MASTER] info: Starting HTTP server on port 3000...
2021-07-21T16:13:47.478Z [MASTER] info: HTTP Server on port: [ 3000 ]
2021-07-21T16:13:47.482Z [MASTER] info: HTTP Server: [ RUNNING ]
2021-07-21T16:13:47.482Z [MASTER] info: πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»πŸ”»
2021-07-21T16:13:47.483Z [MASTER] info:
2021-07-21T16:13:47.483Z [MASTER] info: Browse to http://YOUR-SERVER-IP:3000/ to complete setup!
2021-07-21T16:13:47.483Z [MASTER] info:
2021-07-21T16:13:47.483Z [MASTER] info: πŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”ΊπŸ”Ί
But when I run container IP + port into the browser it shows This site can't be reached
I've already opened ports 80, 443, and 3000 inside the security group attached with this instance. Unable to figure out the reason, why it's not loading wiki.js on the running URL.
It works deliberately in a local docker container, but not in a remote container. Can anyone please help me with this, any help would be appreciated.Thanks in advance.
Same log output but with Postgre in the version I got. I managed to get it working by just running docker start wiki, following the installation process in Wiki.js website.
Have you set the inbound rules of the instance to allow you access over HTTP (not HTTPS)? If yes, you access the instance by just browsing its IP address (No port either as suggested). This is consistent with the local container I set up too.
Make sure the instance has an inbound rule/security group that supports HTTP requests (IPv4 version, TCP protocol, Port range of 80 and the appropriate Source depending on your case).

Nginx Docker Volumes empty

When using docker-compose, nginx isn't showing files like other images might.
For example with Mysql, the below code will save the data created at /var/lib/mysql to the local machine at ./volumes/db/data
./volumes/db/data:/var/lib/mysql
Another example, with Wordpress, the below code will save the data created at /var/www/html/wp-content/uploads to the local machine at ./volumes/uploads/data
./volumes/uploads/data:/var/www/html/wp-content/uploads
This is not working with nginx though so no matter what I change /some/nginx/path to, it never appears at ./volumes/nginx/data
./volumes/nginx/data:/some/nginx/path
Does nginx work differently in this regard?
Update
Using a named volume with the following configurations solved this problem:
In the services section of the docker-compose file, I changed ./volumes/nginx/data:/some/nginx/path to nginx_data:/some/nginx/path
And then my volumes section reads as follows
volumes:
nginx_data:
driver: local
driver_opts:
o: bind
device: ${PWD}/volumes/nginx/data
There should be no difference, a volume is mounting a local directory to a directory in the container. Either you are not mounting correctly or you are mounting an incorrect path inside the nginx container (one which nginx does not use).
Based on the offical nginx docker image docs on https://docs.docker.com/samples/library/nginx/ you should mount to /usr/share/nginx/html
$ docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx
In additonal I would include full paths in your docker-compose.yaml:
volumes:
- /full_path/volumes/nginx/data:/usr/share/nginx/html
If this is still not working you should exec into the container and confirm that the directory is mounted:
$ docker exec -it <container_name> sh
$ df -h | grep nginx
# write data, confirm you see it on the docker host's directory
$ cd /usr/share/nginx/html
$ touch foo
# on docker host
$ ls /full_path/volumes/nginx/data/foo
If any of this is failing I would look at docker logs to see if there was an issue mounting the directory, perhaps a path or permission issue.
$ docker logs <container_name>
--- UPDATE ---
I ran everything you are using and it just worked:
$ cat Dockerfile
FROM nginx
RUN touch /usr/share/nginx/html/test1234 && ls /usr/share/nginx/html/
$ docker build -t nginx-image-test .; docker run -p 8889:80 --name some-nginx -v /full_path/test:/usr/share/nginx/html:rw -d nginx-image-test; ls ./test;
...
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
33ccbea6c1c1 nginx-image-test "nginx -g 'daemon of…" 4 minutes ago Up 4 minutes 0.0.0.0:8889->80/tcp some-nginx
$ cat test/index.html
hello world
$ curl -i http://localhost:8889
HTTP/1.1 200 OK
Server: nginx/1.15.3
Date: Thu, 06 Sep 2018 15:35:43 GMT
Content-Type: text/html
Content-Length: 12
Last-Modified: Thu, 06 Sep 2018 15:31:11 GMT
Connection: keep-alive
ETag: "5b91483f-c"
Accept-Ranges: bytes
hello world
-- UPDATE 2 --
Awesome you figured it out, this post seems to explain why:
docker data volume vs mounted host directory
The host directory is, by its nature, host-dependent. For this reason, you can’t mount a host directory from Dockerfile because built images should be portable. A host directory wouldn’t be available on all potential hosts.
If you have some persistent data that you want to share between containers, or want to use from non-persistent containers, it’s best to create a named Data Volume Container, and then to mount the data from it.
I ran across this issue as well when trying to create a volume to place my own nginx configurations into etc/nginx. While I never found out the real issue I think it has to do with how nginx is built from the Dockerfile.
I solved the problem by using my own Dockerfile to extend the original and copy over the configuration files at build time. Hopefully this helps.
FROM nginx:1.15.2
COPY ./nginx.conf /etc/nginx/nginx.conf
COPY ./global /etc/nginx/global
COPY ./conf.d /etc/nginx/conf.d

Cannot access hawkular metrics

I have install openshift origin 3.9 using inventory file like you. I have used below line for metrics installation:
openshift_metrics_install_metrics=true
openshift_metrics_hawkuler_hostname=hawkular-metrics.example.com
openshift_master_metrics_public_url=https://hawkular-metrics.example.com/hawkular/metrics
And I installed using inventory file with prerequisites.yaml and then deploy_cluster.yaml, so that hawker-cassandra, hawkular-metrics and heapster in running condition and oc adm top node command is working.
But problem is cannot access hawkular metrics by below command:
curl -H "Athorization :Bearer XXXXX" -H "Hawkular-Tenant:openshift-infra" -X GET https://hawkular-metrics.example.com/hawkular/metrics/metics
Showing error:
could not resolve host:hawkular-metrics.example.com,unknown error.
To deploy metrics and access metrics should I need any thing extra for this version?
Is hawkular-metrics.example.com/hawkular/metrics/metics accessible from client? Either a DNS Server or a local /etc/hosts entry should resolve hawkular-metrics.example.com to the node where router pod resides.

Docker "Can't connect to local MySQL server through socket"

I'm new to Docker. I managed to build an image with the things I wanted (CentOS with Apache, PHP, MySQL, MailHog and supervisord.) It works fine.
Now, what I'm trying to do is turn my image (one container) into multiple images/containers: one for web, one for db, etc.
I managed to build those different images, but I'm having trouble linking web and db together via docker-composer.yml. Here is what I have:
web:
container_name: centosweb
image: fab/centosweb
ports:
- "80:80"
volumes:
# Single files
- ./config/httpd.conf:/etc/httpd/conf/httpd.conf
# Directories
- ./vhosts:/var/www/html
- /Users/fabien/Dropbox/AppData/XAMPP/web/bilingueanglais/public_html:/var/www/html/bilingueanglais
- ./logs/apache:/etc/httpd/logs # This will include access_log(s) and error_log(s), including PHP errors.
links:
- db
db:
container_name: centosdb
image: fab/centosdb
volumes:
# Single files
- ./config/my.cnf:/etc/my.cnf
# Directories
- ./mysqldata:/var/lib/mysql
- ./logs/mysql:/var/log/mysql
The output of docker ps is this:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
95048de7a6c4 fab/centosweb "supervisord -n" 14 minutes ago Up 14 minutes 22/tcp, 8025/tcp, 0.0.0.0:80->80/tcp centosweb
eab3047a2dde fab/centosdb "supervisord -n" 14 minutes ago Up 14 minutes 22/tcp, 80/tcp, 8025/tcp centosdb
Trying to connect to my vhosts, I get a database error:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
However, I can connect to centosdb, enter MySQL, and confirm the database is there (i.e.: the db server itself runs fine.)
My understanding so far is that I'm missing a way to tell MySQL to allow connections from the web app instead of the default behavior (connections coming from localhost.) However, I'm confused as to just how to do that.
This is very similar to this question but the latter doesn't contain the specifics I'm looking for.
EDIT: the source of the Dockerfile for the db container.
FROM centos:6.9
# Install MySQL (MariaDB)
# Warning: the repo is super slow in my experience (e.g.: 15 min for 191 MB.)
RUN yum -y update
ADD MariaDB.repo /etc/yum.repos.d/MariaDB.repo
RUN yum install -y MariaDB-server MariaDB-client
# Install supervisord
# EPEL = Extra Packages for Enterprise Linux -- used for python
RUN rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
RUN yum install -y python-pip && pip install "pip>=1.4,<1.5" --upgrade
RUN pip install supervisor
##
# START SERVER
# port 22: SSH
# port 80: TCP, HTTP
# port 8025: MailHog UI (web)
##
ADD supervisord-db.conf /etc/supervisord.conf
EXPOSE 22 80 8025
CMD ["supervisord", "-n"]
# MEMO Β· BUILD THE IMAGE:
# docker build -t fab/centosdb .
How is your application configured to talk to MySQL? Instead of localhost:3306 you need to tell your application to connect to MySQL at db:3306. The link sets a DNS name for the MySQL container as db and your application should be able to resolve this DNS name to get the correct IP address of the MySQL container.

Unable to set endpoint using the Azure CLI

I used docker-machine with Azure as the driver to spin up a VM. I then deployed a simple nginx test container on to the host. My issue is that when I try to set and endpoint I am getting the following error:
azure vm endpoint create huldra 80 32769
info: Executing command vm endpoint create
+ Getting virtual machines
+ Reading network configuration
+ Updating network configuration
error: Parameter 'ConsoleScreenshotBlobUri' should not be set.
info: Error information has been recorded to /Users/ryan/.azure/azure.err
error: vm endpoint create command failed
When I look at the error log it pretty much repeats what the console said Parameter 'ConsoleScreenshotBlobUri' should not be set.
Here are my docker and azure environment details:
❯ docker info
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 3
Server Version: 1.10.2
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 21
Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Plugins:
Volume: local
Network: bridge null host
Kernel Version: 4.2.0-18-generic
Operating System: Ubuntu 15.10
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.636 GiB
Name: huldra
ID: PHUY:JRE3:DOJO:NNWO:JBBH:42H2:56ZO:HVSB:MZDE:QLOI:GO6F:SCC5
WARNING: No swap limit support
Labels:
provider=azure
~/Projects/dockerswarm master*
❯ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ce51127b2bb8 nginx "nginx -g 'daemon off" 11 minutes ago Up 11 minutes 0.0.0.0:32769->80/tcp, 0.0.0.0:32768->443/tcp machinenginx
❯ azure --version
0.9.17 (node: 5.8.0)
❯ azure vm list
info: Executing command vm list
+ Getting virtual machines
data: Name Status Location DNS Name IP Address
data: ------ --------- -------- ------------------- -------------
data: huldra ReadyRole West US huldra.cloudapp.net x.x.x.x
info: vm list command OK