Running Echoip Docker Image - docker

I'm new to Docker and having trouble running the docker image https://github.com/mpolden/echoip#docker-image. What am I doing wrong? Any help would be greatly appreciated!
$ docker run mpolden/echoip -a ./GeoLite2-ASN.mmdb -c ./GeoLite2-City.mmdb -f ./GeoLite2-Country.mmdb
echoip: open ./GeoLite2-Country.mmdb: no such file or directory
The files are in the same directory. To test on your end, download the files: GeoLite2-ASN.mmdb, GeoLite2-City.mmdb, GeoLite2-Country.mmdb: https://gofile.io/d/G4i6hb
Having a docker-compose.yml would make this much easier to run:
version: "3.7"
services:
echoip:
image: mpolden/echoip
command: "echoip -a ./GeoLite2-ASN.mmdb -c ./GeoLite2-City.mmdb -f ./GeoLite2-Country.mmdb"
ports:
- "8080:8080"
restart: unless-stopped

The files are in the same directory
Docker containers cannot access the host filesystem unless it is mounted as a volume. For example, you could mount the current directory to /data in the container...
docker run --rm -v "${PWD}:/data" -p 8080:8080 mpolden/echoip \
-a /data/GeoLite2-ASN.mmdb \
-c /data/GeoLite2-City.mmdb \
-f /data/GeoLite2-Country.mmdb \
-l 0.0.0.0:8080
A Docker Compose config might look like this
version: "3.8"
services:
echoip:
image: mpolden/echoip
command: >
-l 0.0.0.0:8080
-a /data/GeoLite2-ASN.mmdb
-c /data/GeoLite2-City.mmdb
-f /data/GeoLite2-Country.mmdb
ports:
- "8080:8080"
volumes:
- "./:/data"
restart: unless-stopped

Related

Starting docker containers

I have a docker-compose.yml file that starts two services: amazon/dynamodb-local on 8000 port and django-service. django-service runs tests that are dependent on dynamodb-local.
Here is working docker-compose.yml:
version: '3.8'
services:
dynamodb-local:
image: "amazon/dynamodb-local:latest"
container_name: dynamodb-local
ports:
- "8000:8000"
django-service:
depends_on:
- dynamodb-local
image: django-service
build:
dockerfile: Dockerfile
context: .
env_file:
- envs/tests.env
volumes:
- ./:/app
command: sh -c 'cd /app && pytest tests/integration/ -vv'
Now I need to run this without docker-compose, only using docker itself. I try to do following:
docker network create -d bridge net // create a network for dynamodb-local and django-service
docker run --network=net --rm -p 8000:8000 -d amazon/dynamodb-local:latest // run cont. att. to network
docker run --network=net --rm --env-file ./envs/tests.env -v `pwd`:/app django-service /bin/sh -c 'env && cd /app && pytest tests/integration -vv'
I can see that both services start, but I can't connect to the dynamo-db.
Where is the problem? Any comment or help is appreciated!
Through the docker-compose.yml, the amazon/dynamodb-local container has a name defined (container_name: dynamodb-local, If we do not set this property, docker-compose will use the service's name as container name). This enables other containers in the same network to address the container through its name.
In the docker-run command, we do not set an explicit container name. We can set an explicit container name by executing docker run ... --name dynamodb-local .... More details can be found in the corresponding docker run documentation.

What is the equivalent of ‍-h in docker-compose?

I want convert docker run to docker-compose with -h parameter
What is the equivalent of ‍‍‍‍-h in docker-compose?
My docker run command:
docker run --rm -p 8080:80/tcp -p 1935:1935 -p 3478:3478
-p 3478:3478/udp bigbluebutton -h webinar.mydomain.com
My docker-compose
version: "3"
services:
bigbluebutton:
build: .
container_name: "bigbluebutton"
restart: unless-stopped
ports:
- 1935:1935
- 3478:3478
- 3478:3478/udp
- 8080:80
networks:
public:
networks:
public:
external:
name: public
Anything that appears after the docker run image name is the Compose command:.
docker run \
--rm -p 8080:80/tcp -p 1935:1935 \ # Docker options
-p 3478:3478 -p 3478:3478/udp \ # More Docker options
bigbluebutton \ # Image name
-h webinar.mydomain.com # Command
services:
bigbluebutton:
build: .
command: -h webinar.mydomain.com
ports: ['8080:80', '1935:1935', '3478:3478', '3478:3478/udp']

docker-compose up -d failed

I wrote a simple docker-compose.yml as bellow,
version: '3'
services:
ubuntu:
container_name: ubuntu
image: ubuntu
debian:
container_name: debian
image: debian
then ran
$ docker-compose up -d
finally I got two containers with exited status.
even I typed
$ docker start <container_id>
trying to make containers running, but still fail.
Anyone tell me how to fix my yaml file, to make this two containers run with 'docker-compose up -d' ?
The entrypoint and command for these 2 docker images ubuntu and debian will not do anything that keep the container running.
In case you want them to keep running, you can modify your docker-compose file like this
version: '3'
services:
ubuntu:
container_name: ubuntu
image: ubuntu
entrypoint:
- bash
- -c
command:
- |
tail -f /dev/null
debian:
container_name: debian
image: debian
entrypoint:
- bash
- -c
command:
- |
tail -f /dev/null

how to get volume data using ssh connection

I'm trying to pull docker volume data from the remote server. Now my docker volume data is on my local machine. But I want to make this data available to everyone. So I copied docker volume file to the server. How do I show the file path of my docker volume data on this server in the compose file? Like;
docker-compose.yml
version: '3.2'
services:
jira:
container_name: jira-software_8.3
image: atlassian/jira-software:8.3
volumes:
# How to get volume data using ssh connection
- <user_name>#<server_ip>:<server_path>:<container_path>
ports:
- '8080:8080'
environment:
- 'JIRA_DATABASE_URL=postgresql://jira#postgresql/jira_db'
- 'JIRA_DB_PASSWORD=docker'
volumes:
jira_data:
external: false
You can not mount remote server files and folders, docker looking for mounting in the local context.
So the work arround is to copy during run time and mount the directory to a container.
scp -r -i yourkey.pem centos#host.example.com:/home/centos/backup ./app/ && docker run --rm -it -v $PWD/app:/app alpine ash -c "ls /app"
your current docker-compose
volumes:
# How to get volume data using ssh connection
as you can not bind - <user_name>#<server_ip>:<server_path>:<container_path>
scp -r -i yourkey.pem centos#host.example.com:/home/centos/backup ./app/ && docker run --rm -it -v $PWD/app:/app alpine ash -c "ls /app"
below will break your docker-compose
volumes:
# How to get volume data using ssh connection
- <user_name>#<server_ip>:<server_path>:<container_path>
update the docker-compose file
volumes:
- ./app/:/app/
then run docker-compose up command like
scp -r -i yourkey.pem centos#host.example.com:/home/centos/backup ./app/ && docker-compose up

How to convert a docker run -it bash command into a docker-compose?

Given the following command:
docker run -dit -p 9080:9080 -p 9443:9443 -p 2809:2809 -p 9043:9043 --name container_name --net=host myimage:latest bash
How to convert it into an equivalent docker-compose.yml file?
In docker-compose in -it flags are being reflected by following:
tty: true
stdin_open: true
Equivalent to docker run --net=host is this:
services:
web:
...
networks:
hostnet: {}
networks:
hostnet:
external: true
name: host
So your final docker-compose should look like this:
version: '3'
services:
my_name:
image: myimage:latest
container_name: my_name
ports:
- "9080:9080"
- "9443:9443"
- "2809:2809"
- "9043:9043"
command: bash
tty: true
stdin_open: true
networks:
hostnet: {}
networks:
hostnet:
external: true
name: host
Compose file version 3 reference
Last but not least if you want to run it in the detached mode just add -d flag to docker-compose command:
docker-compose up -d
You can’t directly. Docker Compose will start up some number of containers that are expected to run more or less autonomously, and there’s no way to start typing commands into one of them. (What would you do if you had multiple containers that you wanted to start that were all just trying to launch interactive bash sessions?)
A better design would be to set up your Docker image so that its default CMD launched the actual command you were trying to run.
FROM some_base_image:x.y
COPY ...
CMD myapp.sh
Then you should be able to run
docker run -d \
-p 9080:9080 \
-p 9443:9443 \
-p 2809:2809 \
-p 9043:9043 \
--name container_name \
myimage:latest
and your application should start up on its own, successfully, with no user intervention. That’s something you can translate directly into Docker Compose syntax and it will work as expected.

Resources