dockerode | Docker + Node = Dockerode (Nodejs module for Docker's Remote API) | Continuous Deployment library
kandi X-RAY | dockerode Summary
kandi X-RAY | dockerode Summary
Not another Node.js Docker Remote API module.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- build the client
- Attach container to stdout stream .
- pipe logs from container
- Main container process
- run docker container
- Resize container .
dockerode Key Features
dockerode Examples and Code Snippets
Community Discussions
Trending Discussions on dockerode
QUESTION
I'm trying to figure out why dockerode stream directs all data written to the stream directly to the output of the stream.
This is how I create the container, I call the .write()
method on the this.stream
object.
ANSWER
Answered 2021-Apr-08 at 04:42Okay, my current hack to solve this problem is to only read every other on("data", ...)
response. I noticed that the data listener is called twice, once for the command I wrote and the next for the actual output from the shell. So reading every other response prevents this echo. Still looking for a better solution though.
QUESTION
I want to list docker networks with specific name and I've tried to use options like
...ANSWER
Answered 2021-Mar-31 at 09:54Just use Array.prototype.filter
QUESTION
I'm trying to use dockerode to access the Docker API.
My goal is to get container data for all containers in the multi node swarm.
It appears that docker.listContainers( {all: true } )
is scoped to only returns containers running on the calling node, in my case my manager node.
https://docs.docker.com/engine/api/v1.37/#operation/ContainerList
How do we use dockerode to get a list of all the containers in a swarm?
How do we use dockerode to get a list of all the containers associated with a service?
On the command line, you can get the container id using docker service ps
to get the container id, and then call inspect on container.
ANSWER
Answered 2021-Jan-22 at 15:04The docker API will only return locally running containers when using the GET /containers/json
endpoint, so a 404 is expected when trying to return a container on another docker engine. Swarm managers are only able to return swarm objects for the whole cluster. Regular containers are not swarm objects.
When interacting with swarm mode, you can list swarm services and swarm tasks. GET /services
and GET /tasks
. Since tasks are indeed a swarm mode object, you can list all tasks for the whole swarm from any manager.
Tasks do then go on to create containers on the various nodes in the swarm. If you want to list containers across the whole swarm, you must use the GET /containers/json
API endpoint directly on each node.
These API endpoints are analogous to the following commands:
GET /containers/json
-docker container ls
GET /services
-docker service ls
GET /tasks?filter=...
-docker service ps ...
(see documentation for the correct filtering syntax)
I have answered this in the context of the Docker API instead of in the context of any one docker API library for increased readability.
QUESTION
I create docker containers with a node.js app (depends on dockerode API from apocas) with multiple docker networks connected to each container. By default every container gets a random ip address for each network interface.
Example: dev-container with ip: 172.18.0.2 and connected to network demo-net on interface eth4
When I do a docker inspect dev-container
i can see that network demo-net is connected to the container dev-container with ip address 172.18.0.2 (as expected).
Now I execute the dev-container with docker exec -it dev-container /bin/bash
and configure the ip address with ifconfig eth4 192.168.99.169 netmask 255.255.240.0
.
Result: ifconfig
shows that the new address 192.168.99.169 is connected to interface eth4. But when I do a docker inspect dev-container
again, there is still the old address 172.18.0.2 connected with network demo-net (not expected).
Is there a way that docker can update the internal network settings so that docker inspect will show the updated ip settings or is there a better way to change a containers ip address?
(Docker version is 19.03.12)
...ANSWER
Answered 2020-Aug-06 at 09:58Docker will not notice if you try to make manual changes to your container's network configuration. You can docker rm
your container and docker run
it again to bring things back into a consistent state.
By way of analogy, you might try logging into your home WiFi router. It might say your laptop is 192.168.1.2 and your printer is 192.168.1.3. You can certainly run ifconfig
to change your laptop's IP address to 192.168.1.3/24, or to 10.20.30.40/16; but if you do your router won't have any idea this is going on, IP routing won't work correctly if you try to call out (or if you've set up a reverse NAT rule to allow inbound calls back in), and you can get strange network conflicts if you try to print.
Docker completely manages containers' network interfaces. There's no reason to run ifconfig
or ip
in a container. The container-private IP address is really an implementation detail, and it's unusable in many common circumstances; I would also avoid looking this up. You similarly shouldn't need to manually set it, but if you do, the "create a container" Docker API (basically directly exposed by dockerode) lets you specify the NetworkingConfig
.
QUESTION
We've been running a mocha test suite locally for a few months. Today this test runner started to output super verbose information about every function its executing, including from http libraries like axios. How do i reduce the output to only see console.log and spec output?
mocharc.json
...ANSWER
Answered 2020-Jul-29 at 22:59Mocha uses the debug
package. In turn, debug
uses the DEBUG
environment variable.
To enable debug statements in Mocha, we typically use DEBUG=mocha*
. Setting DEBUG=*
would cause any module using debug
to output debug info.
It's likely you (or some program) has set DEBUG=*
or has enabled debug statements via code, e.g.,:
QUESTION
I am attempting to compile & execute a java program within a dockerode container in my node app. I am able to do this by first writing to a tmp.java
file using basic javascript and then running the following shell commands:
docker run --rm -v $PWD:/app -w /app java:8 javac tmp.java
docker run --rm -v $PWD:/app -w /app java:8 java tmp
However, I am now trying to transition to using the dockerode module and am attempting to replicate this functionality as follows (based on the example on the dockerode github):
...ANSWER
Answered 2020-Mar-13 at 06:11The problem is that your directory is not mapped.
This options object is the equivalent of the options --rm -v $PWD:/app -w /app
QUESTION
I'm piping a node stream to stdout but it always writes it in strange manner, every line looks like an object, also as you can see the new line identifier is written.
...ANSWER
Answered 2020-Feb-18 at 12:04Fixed it by doing this instead of stream.pipe(process.stdout)
QUESTION
I am trying to run a docker container using dockerode following the examples here.
The issue I am having is that the output of the container prints to stdout, but I am trying to capture it and store it in a variable while using promises if possible.
My code is:
...ANSWER
Answered 2020-Jan-29 at 08:34For docker.run()
, The [ process.stdout
, process.stderr
] streams are where the underlying stdio data is piped to.
Change these arguments to writable streams you control. You can use something like a memory stream, a file or implement a stream yourself.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install dockerode
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page