Makefile for running docker container with pseudo TTY

Viewed 13

I have a following Makefile:

start: delete-network create-network start-container delete-network

start-container:
    docker run -it --rm --network docky docky bash

create-network:
    docker network create docky

delete-network:
    docker network remove docky 2> /dev/null || true

Unfortunately when I call make start, delete-network task is ignored after I exit from cotainer. How can I execute all tasks?

1 Answers

If running the container and cleaning up is the goal, this will do it:

start: delete-network create-network start-container

start-container:
    docker run -it --rm --network alpine alpine sh; docker network remove alpine

create-network:
    docker network create alpine

delete-network:
    docker network remove alpine 2> /dev/null || true
Related