mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Don't make the user get a container alreayd exists error
Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
This commit is contained in:
parent
42a28f79dc
commit
6a9c6d3bf1
1 changed files with 7 additions and 2 deletions
|
@ -116,8 +116,8 @@ We can also use `docker inspect` to return the container's name.
|
||||||
|
|
||||||
> **Note:**
|
> **Note:**
|
||||||
> Container names have to be unique. That means you can only call
|
> Container names have to be unique. That means you can only call
|
||||||
> one container `web`. If you want to re-use a container name you must delete the
|
> one container `web`. If you want to re-use a container name you must delete
|
||||||
> old container with the `docker rm` command before you can create a new
|
> the old container with the `docker rm` command before you can create a new
|
||||||
> container with the same name. As an alternative you can use the `--rm`
|
> container with the same name. As an alternative you can use the `--rm`
|
||||||
> flag with the `docker run` command. This will delete the container
|
> flag with the `docker run` command. This will delete the container
|
||||||
> immediately after it stops.
|
> immediately after it stops.
|
||||||
|
@ -133,6 +133,11 @@ container, this one a database.
|
||||||
Here we've created a new container called `db` using the `training/postgres`
|
Here we've created a new container called `db` using the `training/postgres`
|
||||||
image, which contains a PostgreSQL database.
|
image, which contains a PostgreSQL database.
|
||||||
|
|
||||||
|
We need to delete the `web` container we created previously so we can replace it
|
||||||
|
with a linked one:
|
||||||
|
|
||||||
|
$ docker rm -f web
|
||||||
|
|
||||||
Now let's create a new `web` container and link it with our `db` container.
|
Now let's create a new `web` container and link it with our `db` container.
|
||||||
|
|
||||||
$ sudo docker run -d -P --name web --link db:db training/webapp python app.py
|
$ sudo docker run -d -P --name web --link db:db training/webapp python app.py
|
||||||
|
|
Loading…
Add table
Reference in a new issue