Docker run command simplify

Dear users,

I`m working with docker for a few weeks and i wondering if there are any easy way to start images.

Sometimes i have NFS share ore datacontainers linked to the container. At this point i have to remember these lines:
docker run -itp 81:80 --name nameofcontainer --link contaimername command of application with parameters.

And i know after a few weeks ore even days i dont know what i did to start this image. Is there any easy why to save this line and start container?

standard procedure is to create a wrapper bash script OR use launch in background with restart always.

Hi,

You should consider using Docker Compose. In Docker compose, you specifies all these parameters in a yml file and just do a compose up command to bring up the container. You can also version this file which will help you remember all the historical changes made to start the docker container.

https://docs.docker.com/compose/.

Also if you are using any configuration management tool , check whether it has a Docker module, where you can script the container launching. If you are not using one yet, I request you to take a look at Ansible, and Ansible Docker module.

A sample docker launch snippet from ansible.

- name: Run Consul Container
  docker:
    name: consul
    image: progrium/consul
    state: started
    ports:
      - "8500:8500"
      - "8301:8301"
      - "8301:8301/udp"
    command: -server -bootstrap-expect 1 -bind {{ ansible_eth1.ipv4.address }}
    net: host
    hostname: consul
    restart_policy: always

Regards