I am new to docker, trying to practice docker-compose commands! My doubt is how to run ubuntu/alpile kind of operating system images using docker-compose?
Here is the docker-compose.yml file:
cat docker-compose.yml
version: “3”
services:
myalpine:
image: alpine
command: sh
myubuntu:
image: ubuntu
Here is the output when i run “docker-compose up” command.
docker-compose up
WARNING: The Docker Engine you’re using is running in swarm mode.
Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.
To deploy your application across the swarm, use docker stack deploy.
Starting docker-compose-1_myubuntu_1 … done
Starting docker-compose-1_myalpine_1 … done
Attaching to docker-compose-1_myubuntu_1, docker-compose-1_myalpine_1
docker-compose-1_myubuntu_1 exited with code 0
docker-compose-1_myalpine_1 exited with code 0
[root@ip-172-31-90-241 docker-compose-1]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
None of the containers are running…!
Can someone help me, how to run these images using docker-compose?
You did! But just having them launch a shell isn’t very interesting; the shell didn’t have any input and exited successfully (“exited with code 0”).
For a next step I’d recommend reading Docker’s tutorial on writing and running custom images. You can then plug these into your docker-compose.yml to build up an application built on top of these base Linux distributions.
What i can understand is, we can’t run container with tty option with docker-compose. Where as we can run the same thing with docker run -it ubuntu option.
You can, but what you’re describing isn’t really an effective use of Docker.
(If nothing else, consider that to change the value of this flag you have to stop, delete, and recreate your container, which will delete its filesystem. So anything you’ve done in an interactive shell in that container is going to get lost, every time you change a basic Docker startup option.)
Ok, so once I have ubuntu running in a container, how do I access it? Most of the apps I have built are accessed via web browser, but there is no port for the Ubuntu image?