Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing docker run command from config file

Tags:

docker

config

I have several arguments in my docker run command like

docker run --rm -v /apps/hastebin/data:/app/data --name hastebin -d -p 7777:7777 -e STORAGE_TYPE=file rlister/hastebin

Can I put all the arguments of this in a default/config file so that I dont have to mention it explicitly in the run command?

like image 939
Amit740 Avatar asked Jan 25 '17 13:01

Amit740


People also ask

How do I run a command Docker?

Running Commands in an Alternate Directory in a Docker Container. To run a command in a certain directory of your container, use the --workdir flag to specify the directory: docker exec --workdir /tmp container-name pwd.

How do I access Docker config file?

The preferred method for configuring the Docker Engine on Windows is using a configuration file. The configuration file can be found at 'C:\ProgramData\Docker\config\daemon. json'. You can create this file if it doesn't already exist.

How do I run a Docker container in CMD?

The basic syntax for the command is: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] You can run containers from locally stored Docker images. If you use an image that is not on your system, the software pulls it from the online registry.

What is use of Docker config file?

Docker swarm service configs allow you to store non-sensitive information, such as configuration files, outside a service's image or running containers. This allows you to keep your images as generic as possible, without the need to bind-mount configuration files into the containers or use environment variables.


1 Answers

You can try docker compose

With Compose, you use a Compose file to configure your application’s services. Then, using a single command, you create and start all the services from your configuration

In your case docker-compose.yml file will looks like

version: '2'
services:
   hastebin:
     image: rlister/hastebin
     ports:
       - "7777:7777"
     volumes:
       - /apps/hastebin/data:/app/data
     environment:
       - STORAGE_TYPE=file

And you can run service by command docker-compose up

like image 165
Bukharov Sergey Avatar answered Sep 30 '22 04:09

Bukharov Sergey