convert docker run to docker-compose.yml special args - docker

I have the folllowing commands that I need to convert to docker-compose
docker run \
-p 993:993 \
-p 587:587 \
-v /home/vmail:/home/vmail \
-e MAILNAME="somedomain.com"
-v /etc/postfix
-v /etc/dovecot
-v /etc/ssl
-v /etc/opendkim
-v /var/log/container:/var/log
email
--email youremail#somedomain.com
How do I pass the --email arg to the ENTRYPOINT using docker-compose?

Docker compose has an entrypoint property which you can use.
...
entrypoint:
-email=youremail#somedomain.com

You could use
command: my_app --email youremail#somedomain.com

I need the same thing, actually how to map ports in compose like docker run -p provides. I still want to use the docker-compose up to start tho.
I think the ports option on docs page is the answer.
Add this to your compose yaml file:
ports:
- "127.0.0.1:<host-port>:<container-port>"

Related

can't control terminal after using the "-t" option in Docker

I am working through the Docker tutorial from here: https://docs.docker.com/language/python/develop/
I have done the first few steps from the tutorial to create a MYSQL container:
$ docker volume create mysql
$ docker volume create mysql_config
$ docker network create mysqlnet
$ docker run --rm -d -v mysql:/var/lib/mysql \
-v mysql_config:/etc/mysql -p 3307:3306 \
### (note: I used 3307:3306 here instead of the specified 3306:3306 because port 3306 was already being used on my machine) ###
--network mysqlnet \
--name mysqldb \
-e MYSQL_ROOT_PASSWORD=p#ssw0rd1 \
mysql
I then followed the next step to check if the mysql container was running:
$ docker exec -ti mysqldb mysql -u root -p
the terminal then prompts:
Enter password:
and I am unable to enter anything. no commands seem to work. ctrl+C didn't even register. the only thing I could do was kill the terminal itself. I am very confused since I have been following the documentation very closely though I am sure it's something very dumb.
Thanks in advance!
Try:
$ docker exec -ti mysqldb bash
then:
mysql -u root -p
I think you can connect with shell first

Unoconv call (openoffice) from other container

I am new in linux and docker. I need to convert odt files to pdf from php container. I use php-5.6-apache and https://github.com/xiaojun207/openoffice4-daemon:
sudo docker build --pull
-t xiaojun207/openoffice4-daemon
–build-arg OO_VERSION=4.1.7 .
sudo docker run -d --restart unless-stopped
-u 123456
–name soffice
–net my-network
-p 8100:8100
-v /data/output-odt:/pdfs/:rw
xiaojun207/openoffice4-daemon:latest
sample of openoffice4-daemon works well from host:
sudo docker run
-v /var/output-odt:/pdfs:rw
xiaojun207/openoffice4-daemon
–net my-network
unoconv --connection ‘socket,host=127.0.0.1,port=8100,tcpNoDelay=1;urp;StarOffice.ComponentContext’
-f pdf /pdfs/test.odt
But I need to execute it from my php container. docker run is not possible from other container. How can I do it? Thanks

How to copy a file folder to docker?

I tried to use the
docker cp :
it always says the
Error: No such container:path:Docker container ID..
Can you tell me how to find the path of the docker(location conatiner) ?
I think the windows file path is correct.
If you want to do it using Dockerfile you can use COPY instruction. Else if you want to do it using docker run command, you can do it the following way:
docker run -d \
--name devtest \
--mount source=myvol2,target=/app \
nginx:latest
or if you want to use docker volume
docker run -d \
--name devtest \
-v myvol2:/app \
nginx:latest
Reference: https://docs.docker.com/storage/volumes/
In your case as you want to mount the host directory to container's, it'll be the former
you can copy files/folder in a container using COPY/ADD command in Dockerfile.
COPY <host-source> <container-dest>
or else you can mount volumes, during docker build or in the docker-compose.yml file.
Eg. for Dockerfile:
docker run -d \
--name devtest \
--mount source=myvol2,target=/app \
nginx:latest
Eg. for docker-compose.yml file
volumes:
- db-data:/var/lib/mysql/data
Dockerfile: https://docs.docker.com/storage/volumes/
docker-compose.yml: https://docs.docker.com/compose/compose-file/
To use docker cp use the instruction as shown:
docker cp ./path/to/local/folder/. ContainerName:/app/
You have to provide the container id/name for container name.
docker ps --filter status=running
The above command will show you the running containers, from where you can select the target container name or id for use (first about 4 characters of the id should be enough)

passing dynamic path in docker run command

I am trying to use this command in docker run
docker run -p 80:80 -v $(pwd)/php-docker/src:/var/www/html/ php-hello-world
but it is not working. Is there any way to use pwd in docker run
yes, you can use PWD, use it as variable $PWD instead subshell $(pwd)
docker run -p 80:80 -v $PWD/php-docker/src:/var/www/html/ php-hello-world

Run bitcoind with bitcoind.conf in docker

I know docker, but less about bitcoind.
Now I want to use this docker image to start my own test environment:
The description tells me:
docker volume create --name=bitcoind-data
docker run -v bitcoind-data:/bitcoin --name=bitcoind-node -d \
-p 8333:8333 \
-p 127.0.0.1:8332:8332 \
kylemanna/bitcoind
Now I want to now how I have to add my bitcoind.conf?
This isn't provided anywere? Can I use it at container startup or docker exec?
The repository contains a documentation file dedicated to your issue: https://github.com/kylemanna/docker-bitcoind/blob/master/docs/config.md

Resources