Couchbase Server Container, inside of a Linux(Centos) container fails to connect - node.js

I have created a Linux Centos container through the following Dockerfile:
FROM centos
RUN cd /etc/yum.repos.d/
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
RUN yum update -y
RUN yum makecache --refresh
RUN yum -y install gdb
Inside that Linux container, I am running a script that first initializes a Couchbase docker image, at http://localhost:8091. After initializing the Couchbase docker image, I try to make an http.request to the Couchbase server that should be up and running, through
http.request({
host: host,
port: 8091,
path: '/'
}
but that doesn’t seem to work. Do you have any ideas as to why it might be happening? Could it be the fact that I haven’t exposed port 8091 in my Linux container? Or could it be that I am not setting up the Couchbase server right? The issue is that I am trying to run a container, inside of another container and then from the outer container(Linux) make a call to the interior one (Couchbase).
Thank you in advance.

Related

Accessing A Web App Running In Docker From Another Machine

I've cloned the following dockerized MEVN app and would like to access it from another PC on the local network.
The box that docker is running on has an ip of 192.168.0.111 but going to http://192.168.0.111:8080/ from another PC just says it can't be reached. I run other services like plex and a minecraft server that can be reached with this ip so I assume it is a docker config issue. I am pretty new to docker.
Here is the Dockerfile for the poral. I made a slight change from the repo adding -p 8080:8080 because I read elsewhere that it would open it up to lan access.
FROM node:16.15.0
RUN mkdir -p /usr/src/www &&
apt-get -y update &&
npm install -g http-server
COPY . /usr/src/vue
WORKDIR /usr/src/vue
RUN npm install
RUN npm run build
RUN cp -r /usr/src/vue/dist/* /usr/src/www
WORKDIR /usr/src/www
EXPOSE 8080
CMD http-server -p 8080:8080 --log-ip
Don't put -p 8080:8080 in the Dockerfile!
You should first build your docker image using docker build command.
docker build -t myapp .
once you've built the image, and confirmed using docker images you can run it using docker run command
docker run -p 8080:8080 myapp
Docker listens 0.0.0.0 IP address and the other machines on the same network can use your ip address to show your website on which port did you use for sharing. For example you use 8080 and actually you listen 0.0.0.0:8080 and the other machines http://192.168.0.111:8080/ can reach that website with your ip address. Without docker you can also listen 0.0.0.0 to share your app on network.
The box that docker is running on
What u mean by saying "BOX"? Is it some kind of virtual box or maybe actual computer with Linux or Windows or maybe MacOS?
Have u checked particular "BOX"'s firewall? (u may need to do "NAT" over firewall to particular in "BOX" running service for incoming requests from outside of "BOX").
I'll be happy to help u our if u'll provide more detailed information about your environment...

Running Splash on Docker Toolbox with Windows 10

I am trying to install and run splash on using Windows 10 Home. I have installed docker toolbox, as on windows 10 Home you can't install docker. Then in command prompt when I type
docker pull scrapinghub/splash
I get the error
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/images/create?fromImage=scrapinghub%2Fsplash&tag=latest: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
One interesting thing I noticed was that if I run Docker Quickstart Terminal I can install splash with the command
docker pull scrapinghub/splash
and then using the command
docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 scrapinghub/splash
it gives me
server listening on http://0.0.0.0:8050
But then when I paste http://0.0.0.0:8050 into Chrome it gives me "This site can't be reached."
Thanks
So 1st error clearly says that your Docker container is not running, so your pull command fails
You can check by running any docker command maybe try this
docker --version
For your 2nd query, you need to use Docker IP, to access the application
You can try docker-machine ip to see, on what IP docker is running (Assuming docker-machine is installed)
Generally, on windows Docker IP is 192.168.99.100
Try these 2
192.168.99.100:8050
or
localhost:8050

Port problems to access a service inside a container

I'm posting for a friend. He asked my help and we couldn't find out what's going on.
My situation is: my application works perfectly on Ubuntu 18.04 when it’s not inside a container, but the customer required the use of containers so I created a Dockerfile so it could be started by a Docker container.
Here’s the contente of my Dockerfile
FROM node:8.9.4
ENV HOME=/home/backend
RUN apt-get update
RUN apt-get install -y build-essential libssl-dev
RUN apt-get install -y npm
COPY . $HOME/
WORKDIR $HOME/
RUN npm rebuild node-sass
RUN npm install --global babel-cli
USER root
EXPOSE 6543
CMD ["babel-node", "index.js"]
After building the image, I execute the following Docker run command:
sudo docker run --name backend-api -p 6543:6543 -d backend/backendapi1.0
Taking a look at the log output, I can conclude that the application Works properly:
I’ve created a rule in my nginx to redirect from port 90 to 6543 (before using containers it used to work)
server {
listen 90;
listen [::]:90;
access_log /var/log/nginx/reverse-access.log;
error_log /var/log/nginx/reverse-error.log;
location / {
proxy_pass http://localhost:6543;
}
}
P.S.: i’ve tried to change from localhost to the container’s IP and it doesn’t work as well.
The fun fact is that when i try na internal telnet on 6543 it accepts the connection and closes it immediately.
P.S.: all ports are open on the firewall.
The application Works normally outside the container (using port 6543 and redirecting in nginx)
I’d appreciate if someone could help us to find out the reason why it’s happening. We don't have much experience creating containers.
Thanks a lot!
Edit: it's an AWS VM, but this is the return when we run the command curl:
We found the solution!!
It was an internar container router problem...
The following Docker run command solved the problem:
sudo docker run --name my_container_name --network="host" -e MONGODB=my_container_ip -p 6543:6543 my_dockerhub_image_name
Thanks a lot!!

AWS Linux (Ubuntu) hosted application is not accessible from public ip

I hosted a nodejs(express hello world app) application on AWS Linux(Ubuntu 16.04) on free-tier. When i do wget http://localhost:8080 it runs successfully and saved the output in index.html file.
But when i do the same thing with the public ip (wget http://35.154.40.189:8080) of my instance, it says
Connecting to 35.154.40.189:8080... failed: No route to host.
I also used the steps given in http://www.lauradhamilton.com/how-to-set-up-a-nodejs-web-server-on-amazon-ec2 to forward all ipv4 traffic to my application but it doesn't work.
I also enabled port 8080 from aws console.
netstat -atn says
netstate -ntlp says
I tried everything which i get on internet but unable to resolve the issue. Now i'm too much frustrated. Any help would be highly appreciable.
MAke Your Instance in AWS first
Enable inbound rule as u mention in picutre
Enable user group after ssh connection with AWS ubuntu instance
once instance start running then Install node properly
sudu apt-get update
sudo apt-get install libssl-dev g++ make
download source code of node from web node.tar.gz wih command wget link
https://nodejs.org/dist/v6.9.1/node-v6.9.1.tar.gz
tar -xvf node -v0.10.32.tar.gz
now goto node after unzip .gz
./configure && make && sudo make && sudo make install
boom your node server is ready on new AWS instances
or watch this https://www.youtube.com/watch?v=WxhFq64FQzA&t=1693s

Docker container with Node and Express on Mac, not showing in browser?

I'm delving into Docker and I'm trying to rack my brains on why this isn't working for me. I've read many articles and tutorials on how to setup this up and I seem to have everything in place, but my actual app just isn't showing up in the browser (localhost:3001). I'm using the latest version of Docker on my Mac, running Mavericks, using boot2docker. I definitely have boot2docker running as the docker commands run fine and I get no errors that seem to relate.
The super simple project looks like this:
src/
..index.js
..package.json
Dockerfile
The src/index.js file looks like this:
var express = require('express'),
app = express();
app.get('/', function(req, res){
res.send('Hello world!');
});
app.listen(3001);
The src/package.json file looks like this:
{
"name": "node-docker-example",
"version": "0.0.1",
"description": "A NodeJS webserver to run inside a docker container",
"main": "index.js",
"dependencies": {
"express": "*"
}
}
The Dockerfile file looks like this:
FROM ubuntu:14.04
# make sure apt is up to date
RUN apt-get update
# install nodejs and npm
RUN apt-get install -y nodejs npm git git-core
# add source files
ADD /src /srv
# set the working directory to run commands from
WORKDIR /srv
# install the dependencies
RUN npm install
# expose the port so host can have access
EXPOSE 3001
# run this after the container has been instantiated
CMD ["nodejs", "index.js"]
With all of this in place, I then build it just locally:
$ docker build -t me/foo .
No problems... Then I've tried some alternative ways to make it run, but none of these work and I can't see any response when viewing in my browser (localhost:3001)
$ docker run -i -t me/foo
$ docker run -i -t -p 3001:3001 me/foo
$ docker run -i -t -p 127.0.0.1:3001:3001 me/foo
Nothing seems to work, no errors come up... Well, apart from that localhost:3001 in the browser does absolutely nothing.
Please help me! I love the idea of docker, but I can't get the simplest thing running. Thanks!
boot2docker has an extra network
There's one extra layer of networking getting in the way. Remember that boot2docker has it's own OS and additional network IP, so try url=http://$(boot2docker ip):3001;curl -v "${url}" from a terminal on your mac and see if that returns HTML from your express app. If so, you can browse to your app with open "${url}".
I was able to take your files (thank you for posting full files!) and build and run your image locally.
Build, run, and test it like this
docker build -t foo .
docker run -i -t -p 3001:3001 foo
I think the key thing to note is that for docker build the -t argument means "tag" but for docker run it means "allocate a tty".
Test it like this (in a separate terminal from where it's running interactively)
curl -s "$(boot2docker ip):3001"
Here's where you went wrong
Or at least my guesses:
$ docker run -i -t me/foo
doesn't map any ports
$ docker run -i -t -p 3001:3001 me/foo
I think in theory this variant should work. If not, I'm pretty sure it's a boot2docker-specific networking issue at the IP layer.
$ docker run -i -t -p 127.0.0.1:3001:3001 me/foo
This is telling docker to bind to loopback on the docker server, not your mac, so you'll never be able to connect to this from your mac.

Resources